Jump to content

Styling An Inline Element


skaterdav85

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...