Is it not necessary to close the tag in HTML 5 like HTML? or it's a bug in W3C validator
Why this code is valid in W3C validator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<p>Some Text
</body>
</html>
I would be surprised if it's really valid in HTML5. But is there any benefit to keep this behavior valid in HTML5. Do HTML5 creators think that stricter rules of XHTML were not good for Web?
Optional HTML Closing TagsSome closing tags are optional, however. The tags are optional because it's implied that a new tag would not be able to be started without closing it.
If you don't add a closing tag the browser won't know where it ends. It will take the next tag and think it belongs to the previous tag without the closing tag.
There are some HTML elements which don't need to be closed, such as <img.../>, <hr /> and <br /> elements. These are known as void elements.
That markup is indeed valid. <p>
tags don't have to be closed in HTML 4.01 or HTML5. I'm not sure where you got the idea that HTML5 requires everything to be closed like in XHTML.
HTML5 is just regular HTML with extra new features (hence the version jump from 4.01 to 5). It does not in any way derive from XHTML. You can close all of your HTML5 tags so it looks like well-formed XML, but the spec doesn't require you to.
Do HTML5 creators think that stricter rules of XHTML were not good for Web?
Pretty much, yes.
Their view is that it just makes creating a web page harder. HTML has been wildly successful because just about anyone can create a working web page without knowing barely any HTML at all. It's a very small learning curve to get started which people can build upon when they're ready.
If you need to know a lot of pedantic rules just to get started, then many people won't bother, and HTML will not be as successful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With