9

I have a bit of problem when trying to validate my page as HTML5. There are two errors. The first says, 'Element head is missing a required instance of child element title', and the second error is, 'Element hr not allowed as child of element ul in this context. (Suppressing further errors from this subtree)'.

Here is my source code

<!DOCTYPE html>

<html lang="en">

<head>

<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>

<link rel="stylesheet" href="core/css/style.css">

</head>

<body>

<nav>

<h1>Name</h1>

<ul>

<hr>

<li><a href=".."><img src="core/images/home.png" alt="Home"></a></li>

<hr>

<li><a href=".."><img src="core/images/about.png" alt="About"></a></li>

<hr>

<li><a href=".."><img src="core/images/projects.png" alt="Projects"></a></li>

<hr>

</ul>

</nav>

-Thank you in advance for any help

4
  • 5
    The error messages seem pretty self-explanatory to me. You are missing a <title> from the head and you can't have <hr>s inside <ul> tags. Commented Apr 3, 2012 at 10:12
  • Thank you, so what can I use instead of the <hr> tags within the <ul> tags? Commented Apr 3, 2012 at 10:14
  • 1
    Why are you using lists anyway? Just use divs instead. Or style the list elements so that they have a top or bottom border. Commented Apr 3, 2012 at 10:15
  • @Juhana as it's a navigation menu I would say that list tags are the correct markup. OP should apply CSS to achieve the desired look. Commented Apr 3, 2012 at 10:19

2 Answers 2

12

As Juhana's comment points out the errors are self-explanatory:

Element head is missing a required instance of child element title

This means you are simply missing a <title> tag in your <head> tags. You should definitely give your page a title!

Element hr not allowed as child of element ul in this context

By there very nature, <ul> (unordered list) tags can only contain <li> (list item) tags. You are wrong to use a horizontal-rule inside your list. You can achieve the same effect with CSS. I suggest read a few more tutorials on HTML and basic CSS.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks you :)! I've fixed it now just added a border-bottom to my <ul> tag and it worked :D
5

I had the same problem with <hr> tags inside an <ul>. Instead of applying new css rules to your list you just have to contain <hr> inside of a <li>.

<ul>
  <li><hr/></li>
  <li>text</li>
</ul>

Then all of your elements inside of a <ul> are properly nested and contained. No extra work necessary.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.