Convert HTML to XHTML – nested tags.

There are three main points to consider when using nested tags in XHTML.

1. If you apply multiple tags to your web pages make sure you open and close them in the correct order.

2. Some elements in HTML may be improperly nested within each other like this:


<b><i>This text is bold and italic</b></i>  

This is how the code should be nested correctedly in XHTML:


<b><i>This text is bold and italic</i></b>

3. A common mistake in nested lists, is to forget that the inside list must be within a li element, like this:


<ul>
  <li>Coffee</li>
  <li>Tea
    <ul>
      <li>Black tea</li>
      <li>Green tea</li>
    </ul>
  <li>Milk</li>
</ul>

This is correct:

<ul>
  <li>Coffee</li>
  <li>Tea
    <ul>
      <li>Black tea</li>
      <li>Green tea</li>
    </ul>
  </li>
  <li>Milk</li>
</ul>

Notice that we have inserted a </li> tag after the </ul> tag in the “correct” code example.

Proper nesting of tags within your XHTML code will make your web pages cleaner, lighter and faster loading.

Trackbacks

Speak Your Mind

*