Reputation: 89613
Good afternoon all,
I've just realised that this piece of code validates as 100% valid HTML5:
<!doctype html>
<html>
<title>asd</title>
<script src="Js.js"></script>
<script>alert('1');</script>
</html>
MDN states that the permitted parent elements of the <script>
tag is:
Any element that accepts metadata elements, or any element that accepts phrasing content. (source)
I was wondering does anyone know what does a metadata element mean? What does phrasing content mean?
Upvotes: 3
Views: 1406
Reputation: 133
Here is a link defining what they mean by metadata elements and phrasing elements. Hope that clears up which is which. http://www.w3.org/TR/html-markup/common-models.html#common.elem.metadata
Upvotes: 2
Reputation: 318488
Elements belonging to the metadata content category modify the presentation or the behavior of the rest of the document, set up links to others documents, or convey other out of band information.
Elements belonging to this category are
<base>
,<command>
,<link>
,<meta>
,<noscript>
,<script>
,<style>
and<title>
.
Source: https://developer.mozilla.org/en/HTML/Content_categories#Metadata_content
The reason why your document validates even without <head>
and <body>
is that they became optional in HTML5. Actually, even <html>
is optional so the following code is valid HTML5, too:
<!doctype html>
<title>asd</title>
<script src="Js.js"></script>
<script>alert('1');</script>
Upvotes: 2