skaterdav85 Posted September 26, 2011 Share Posted September 26, 2011 If I want to create a blue box on a page using a span, how come I have to declare it as a block element using display:block, rather than just assigning it a width and height? I.e. span { width:100px; height:100px; background-color:blue; display:block; } instead of span { width:100px; height:100px; background-color:blue; } Link to comment Share on other sites More sharing options...
Ahmad Fayed Posted September 26, 2011 Share Posted September 26, 2011 Use <div> Just Use <span> for text .. My Friend taught me that .. and by trial and experience, I concluded that was a good advice Link to comment Share on other sites More sharing options...
skaterdav85 Posted September 26, 2011 Author Share Posted September 26, 2011 well in my case, i am using anchor tags instead, and it presents the same problem because anchors are also inline elements, so I wanted to know why. Link to comment Share on other sites More sharing options...
Ingolme Posted September 26, 2011 Share Posted September 26, 2011 Inline elements are not allowed to use certain properties, such as width, height and margin. Padding works, but only horizontal padding.If you want an inline element to have block properties, but remain inline, then set its display to inline-block. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.