Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,254 Points

Invalid HTML markup

Here's a little HTML markup snippet for you.

<ul class="class-name">
  <a href=""><li class="class-name">Study Hall</li></a> 
</ul> 

I copied this from a codepen from another question because it piqued my interest on something.

If I want to do mobile navigation and make a background colour in CSS that is completely clickable I do might do something like the above so the clickable area completely covers the background area i.e. the content area.

Only, as I suspected, it's not valid code. But is this okay? Does it affect anything negatively such as SEO, Search ranking? Or just someone who doesn't happen to like what they see when they look at your source code :)

I think I've run into this before. I think I did this on a site a while ago and had it return as invalid code. I don't think it was a problem although it wasn't being developed for mobile at the time.

I asked a question here on the forum that was related to this - I asked why styling for a link was applied to the parent li tag.

Could a work around be to apply inline-block styling to the a link? Which would allow specifying width and height dimensions to a background that is clickable?

2 Answers

Jacob Herper
Jacob Herper
94,150 Points

You should put the link tag <a> inside the list element <li>:

  <li class="class-name"><a href="">Study Hall</a></li>

Sorry, I meant to say, my question was about applying inline-block styling to the a link AFTER it is inside the li element.