HTML Span Inline
Inline-level elements
Unlike block elements inline elements don't form a whole block and are only as wide as their content.
Furthermore all content is distributed in lines which means that the height can't be changed. This also applies to the vertical padding and margin. However, you may modify the width as well as the horizontal padding and margin.
To correctly validate in XHTML 1.0 strict all inline elements must be inside block-level elements and can only contain inline content. Note that the body tag does not count as block element, thus just having some text without paragraph elements between the body tags would produce an error.
A good example for an often used inline element is the <strong> tag:
Strong inline-level element:
- <p>A paragraph with some <strong style="border:1px solid">strong inline text</strong> in the middle.</p>
Display:
A paragraph with some strong inline text in the middle.
Span
The inline counterpart to the div block-level element is the span. It has no semantical meaning and can be used as often as you like to style inline content.
Have a look at the following example which makes use of the span element to change the font size of a text part:
HTML span:
- <p>Another paragraph with some <span style="font-size:2em">big text</span> in-between.</p>
Display:
Another paragraph with some big text in-between.
List of XHTML inline-level elements
Here's a list of common XHTML 1.0 strict inline-level elements:
- span
- img
- strong
- em
- a
- input
- textarea
- select
- option