I have this HTML code:
<body> <div id='div0' style='display:inline; background-color:green; width:100%'> <div id='div1' style='display:inline; background-color:aqua;width:33%'> </div> <div id='div2' style='display:inline; background-color:red;width:33%'> </div> <div id='div3' style='display:inline; background-color:yellow;width:33%'> </div> </div> </body>
I want to fill the page with div1, div2 and div3 but they don’t fill the entire width.
What it’s happening?
Taken from display declaration:
You cannot give an inline element set width or height dimensions, they will be ignored. An element must have a display type of
blockto do that. Settingdisplay: blockhowever will not achieve what you want since each element will fill the entire width.float: leftwill cause them to stack to the left and also forcesdisplay: block.Mmmmm, semantics
See answer from Phunky for further comments on floating.