This page is a work in progress.You can help improve it. →

Nesting elements

You can put elements inside other elements as well — this is called nesting. If we wanted to state that our cat is very grumpy, we could wrap the word "very" in a <strong> element, which means that the word is to be strongly emphasized.


<p>My cat is <strong>very</strong> grumpy.</p>

You will need to make sure that your elements are correctly nested: in the example above, we opened the p element first, then the strong element, which would mean we have to close the strong element first, then the p. The following is incorrect:

<p>My cat is <strong>very grumpy.</p></strong>

The elements have to open and close correctly, so they are clearly inside or outside one another. If they overlap like above, then your web browser will try to make the best guess at what you were trying to say, and you may well get unexpected results. So don't do it!


© 2017 - 2022; Built with ♥ in St. Petersburg, Florida.