the width attribute does not work in the table, why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

the width attribute does not work in the table, why?

https://code.sololearn.com/WBg8zL0hvW3Q/?ref=app the "height" attribute is applied to the "<th>" tag and the "width" attribute is not present why?

3rd Nov 2017, 12:24 PM
Aleksandr Nazimov
Aleksandr Nazimov - avatar
7 Answers
+ 7
In <table> context, use 'min-width' instead 'width' to force size (default behaviour try to not overflow available space and limit table width to available space -- instead you could set the explicit width required by the <table> element once added all borders, border-spacing and cell widths ^^)
3rd Nov 2017, 1:55 PM
visph
visph - avatar
+ 6
@Lord Krishna: 'width' property is supported, but should only be respected if available width is enough ;P
3rd Nov 2017, 1:58 PM
visph
visph - avatar
+ 5
Sure it works, else I would not have posted that ;P
3rd Nov 2017, 2:14 PM
visph
visph - avatar
+ 2
use css codings.
3rd Nov 2017, 1:27 PM
Elizabeth🌸
Elizabeth🌸 - avatar
+ 1
th{ height:50px; width:100px; /*why does not it work ?*/ border-style:solid; border-width:1px; }
3rd Nov 2017, 1:33 PM
Aleksandr Nazimov
Aleksandr Nazimov - avatar
0
thanks
3rd Nov 2017, 2:08 PM
Aleksandr Nazimov
Aleksandr Nazimov - avatar
0
th{ height:50px; min-width:50px; border-style:solid; border-width:1px; } this works 😁
3rd Nov 2017, 2:12 PM
Aleksandr Nazimov
Aleksandr Nazimov - avatar