HTML Text Formatting

There are two type of HTML tags: inline and block elements. Block elements are rendered stacked on the page, while inline elements are rendered in a row by default (this can be changed with CSS).

Block elements: <h1>, <p>, <div> etc.

Inline elements: <img />, <span>, <strong>, <em> etc.

The inline tags below are used to style the text in our document. We can overwrite the default look with CSS.

The <u> (underline) tag is obsolete and <span style="text-decoration: underline;"> should be used to underline the text.

The Span Tag

The span tag doesn't show any visual difference without using CSS styles. This tag is used to group inline elements such as text in the document.

<p>
  The 
  <span style="font-size: 1.2em">
    Rubik's Cube
  </span> 
  is the 
  <span class="htmlpage">
    best-selling puzzle toy 
    <span style="text-decoration: underline;">
      of all time
    </span>
  </span>.
</p>

The Rubik's Cube is the best-selling puzzle toy of all time .