In this exercise we nested an `<img>` element within an `<a>` element to make images clickable links. Can we nest any element within `<a>` tags? (li elements?)


#1

Question

In this exercise we nested an <img> element within an <a> element to make images clickable links. Can we nest any element within <a> tags? (li elements?)

Answer

With HTML5, the <a> tag can now contain both inline and block-level elements. For example, we can nest heading elements within <a> tags like so:

<a href=”#”><h1>Example</h1> </a>

This would make the entire <h1> element clickable!

That having been said, one block-level tag which we do not want to nest within an <a> tag is the <li> tag. <li> tags should always be direct children to either <ol> , <ul>, or the experimental <menu> tags.

To learn more about inline and block-level elements, check out our “Learn CSS” course.


FAQ: Learn HTML Elements - Common HTML Elements - Linking At Will
#2

Why can’t I see ‘Example’ in this answer?


#3

Because the markup wasn’t right, you should be able to see it now.