Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a HTML5 "metadata element"?

Tags:

html

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?

like image 934
Pacerier Avatar asked Jul 11 '26 00:07

Pacerier


1 Answers

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>
like image 79
ThiefMaster Avatar answered Jul 13 '26 14:07

ThiefMaster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!