Jump to content
skaterdav85

Styling An Inline Element

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; }

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...