Reputation: 451
Can somebody explain why this HTML document won't validate as HTML5 (using http://validator.w3.org/)? I get three errors:
<!DOCTYPE html> //Random comment
<html lang="sv"> //Random comment
<head>
<meta charset="utf-8" /> //Random comment
<title>Startsida - Läxhjälpen</title> //Random comment
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link href="laxhjalpen.css" rel="stylesheet" /> //Random comment
</head>
<body class="startpage"> //Random comment
<header> //Random comment
<div class="hwrap"> //Random comment
<a href="./"><img class="logo" alt="Startsidan" src="./Images/laxlogo.png" /></a> //Random comment
<h1>Läxhjälpen</h1> //Random comment
</div>
<p class="tagline">Vi hjälper dig att förstå!</p> //Random comment
</header>
//Random comment
<section class="menu"> //Random comment
<h2><a href="om-oss.html">Om oss <span style="color:blue;">〠</span></a></h2>
<p>Man måste inte vara plugghäst för att kunna plugga. Vi själva är exempel på det.</p>
</section>
<section class="menu"> //Random comment
<h2><a href="arbeten.html">Vad vi gör <span style="color:grey;">⌘</span></a></h2>
<p>Vi hjälper dig att plugga alla ämnen i skolan och förbereda dig för prov på bästa möjliga sätt.</p>
</section>
<section class="menu"> //Random comment
<h2><a href="blog.php">Blogg ✪</a></h2>
<p>Ta del av andra människors erfarenheter med vår tjänst.</p>
</section>
<section class="menu"> //Random comment
<h2><a href="contact.php">Kontakt ☎</a></h2>
<p>Kontaktformulär, telefonnummer och adresser för att kontakta oss.</p>
</section>
<footer>
<small>© Måns Nilsson AB</small> //Random comment
</footer>
</body>
</html>
Upvotes: 1
Views: 444
Reputation: 334
You should be using <!--Random comment-->
INSTEAD of //Random Comment
HTML comments =
//
This is usually used within PHP or JQuery to comment out A LINE
Upvotes: 0
Reputation: 943547
//Random comment
is not a comment in HTML. It is text content. Since such content is only allowed in the body (and the title), this generates an html element containing a head element (without a title) and a body element.
(Note that while html, head and body elements are required, the start and end tags for those elements are optional. The start and end tags for the title element are mandatory which is why the text ends up in the body and not the title)
<!-- This is an HTML comment -->
Upvotes: 8