Which HTML Selectors are block elements and which are inline elements by default?

Posted Posted by jerothe in XHTML / HTML     Comments No comments
Oct
21

We have talked about the display property before, but I just wanted to make note here what the defaults are for a select few HTML Selectors.

Elements that default to display:block, and will force a break, are;

p, h1, and div

Elements that default to display:inline and will stay as the name says, inline with other elements, are;

strong, span, and em

Remember, you can change the rules for all of these selectors in your external style sheet in how they display. Here is an example of what you write;

h1, h1, h3 {

display:inline;

}

span {

display:block;

}
In the second example for the redefined span tag, here is what would happen.

The redefined span element with a display of block will now force a break mid line.

Post comment