Re: Validator didn't see that I nested the meta tags in the title tags

2013-09-23 13:33, Eric Roxas wrote:

> This didn't come out as an error.

It isn't an error

> <!doctype html>
> <html>
> 	<head>
> 		<title>
> 			Journey with a segway
> 		<meta charset="utf-8">
> 		<link type="text/css" rel="stylesheet" href="journal.css">
> 		</title>

This is valid, because the content of the title element is treated as 
plain text. Only the end tag </title> is recognized; otherwise, 
everything is taken as-is, except that character references (like 
&eacute; and &#x123;) are parsed and interpreted.

You can see what happens in browsers by appending the following to the 
document:

<script>
console.log(document.title)
</script>

When you look at the console log, you will see

Journey with a segway <meta charset="utf-8"> <link type="text/css" 
rel="stylesheet" href="journal.css">

and this is also used as the title otherwise. The <meta> and <link> tags 
are not recognized here at all.

It might be a good idea to issue a warning when the title element 
contains the less-than character "<". Cases where the title 
intentionally contains that character must be very rare as compared with 
unintentional appearances (often caused by attempts to use markup inside 
the element).

Yucca

Received on Monday, 23 September 2013 17:35:14 UTC