why my table size is smaller when i use <!doctype html> in html | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
1st Sep 2019, 6:08 PM
Mohammad Jafer
Mohammad Jafer - avatar
10 Answers
+ 9
Mohammad Jafer I'm surprised there weren't more issues in these codes. The <table> tag was actually between the <head> and <body> tags and there was an extra closing </table> tag. Regardless, it helps to know what DOCTYPE does. Without it, the browser will likely default to a quirks mode to support a legacy version of HTML where some values are automatically applied without being explicitly set. In this case, the table is set to a height of 100%. This applies to 100% of its parents, which are html and body. Well... it should be body when the HTML is properly structured. 😉 My guess is quirks mode will assume table height to be 100% of the page when height hasn't been explicitly set on either parent. That would explain the behavior. When DOCTYPE is present, HTML will follow the standard specified which is expected to behave the same across all browsers. Note, legacy quirks mode can be different from browser to browser. So, in standards mode, the table will only be 100% relative to its parent tags.
1st Sep 2019, 7:55 PM
David Carroll
David Carroll - avatar
+ 5
Please mention 'HTML table' in Relevant Tags - and attach your code link in Description section so everyone can see it to suggest and/or help you. Good luck! 👍
1st Sep 2019, 6:30 PM
Ipang
+ 5
Here's another version you can compare against: https://code.sololearn.com/WybUsifI7qlZ/
1st Sep 2019, 7:56 PM
David Carroll
David Carroll - avatar
+ 4
Ipang Jamie💐 David Carroll I don't understand why when I use <!doctype html> my table gets bigger or smaller https://code.sololearn.com/WdOUaPl35sG2/?ref=app https://code.sololearn.com/W4r10Fwa5q31/?ref=app
1st Sep 2019, 7:25 PM
Mohammad Jafer
Mohammad Jafer - avatar
+ 4
Mohammad Jafer I must've already fallen asleep when you replied, and just got the chance to return now, but I see you confirmed with the code links,, and also have gotten your solution 👍 Thanks moderator David Carroll, Jamie💐 , and Lord Krishna
2nd Sep 2019, 8:21 AM
Ipang
+ 2
P.B Can you expand on your answer? I'm not able to follow your logic.
3rd Sep 2019, 4:18 AM
David Carroll
David Carroll - avatar
+ 1
I think because some element are not supported in HTML5 so u need the <!DOCTYPE>
3rd Sep 2019, 3:19 AM
P.B
P.B - avatar
+ 1
I'm tryna say that <!DOCTYPE html> enable the use of html5 elements like colspan and border in d table when u remove it.. It will be vague,i guess💁
3rd Sep 2019, 1:47 PM
P.B
P.B - avatar
+ 1
P.B Ah gotcha... That explanation was much clearer. That said, I provided an answer earlier that might help explain the reasoning. 😉👌
3rd Sep 2019, 5:57 PM
David Carroll
David Carroll - avatar
+ 1
👌👌😂
4th Sep 2019, 2:38 AM
P.B
P.B - avatar