+ 5
why my table size is smaller when i use <!doctype html> in html
html https://code.sololearn.com/WdOUaPl35sG2/?ref=app https://code.sololearn.com/W4r10Fwa5q31/?ref=app
10 Réponses
+ 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.
+ 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! 👍
+ 5
Here's another version you can compare against:
https://code.sololearn.com/WybUsifI7qlZ/
+ 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
+ 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 ✌
+ 2
P.B Can you expand on your answer? I'm not able to follow your logic.
+ 1
I think because some element are not supported in HTML5 so u need the <!DOCTYPE>
+ 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💁
+ 1
P.B Ah gotcha... That explanation was much clearer.
That said, I provided an answer earlier that might help explain the reasoning. 😉👌
+ 1
👌👌😂