There are two HTML specifications: W3C and WHATWG, which one to believe?
Believe the one you like most, but don't forget to check with browsers.
Specification is the main source of knowledge: both for browsers and for developers. Browsers process the code by specs, developers write code by specs - and everything works well together. This is called “web standards” and you don’t want to know how bad everything was until they were widely accepted.
W3C is a worldwide web consortium, a non-profit organization that develops the technologies on which the web works. WHATWG is an independent hypertext web application technology working group that was assembled as part of the W3C in the mid-2000s. Collected not just like that, but in the case.
Sometime in the W3C they decided to abandon the HTML 4 specification and start developing XHTML, more rigorous, formal, and, as it later became clear, too out of touch with reality. In response, the WHATWG, which included representatives of browsers, gathered. Because of this, the HTML 5 specification appeared with a lot of really useful things. From the XHTML remained only the habit of closing tags and quoting attributes.
After the release of HTML 5 from the WHATWG, the specification followed the formal path to the W3C recommendation and reached it in 2014. But something went wrong along the way, and there was disagreement between the WHATWG and the W3C. Because of this, differences between versions began to appear. In 2011, WHATWG abandoned HTML numbering altogether and began to develop the specification as a living standard, in the spirit of evergreen browsers.
In summary, we now have two specifications: the HTML 5.1 recommendation for the W3C and the live HTML standard for the WHATWG. And each has its own goals: HTML5 takes snapshots of reality, numbers them and issues recommendations. This answers the question of developers: what is already in browsers? WHATWG, on the contrary, tries to get ahead of reality, to offer something new and to predict changes. This is closer to the tasks of browsers.
So what's the controversy? For example, the W3C recommends having just one main element on a page, equating it to the main ARIA role. This helps screen readers find the most important thing on the page. WHATWG allows main in any structural element, as its main part, in the manner of header and footer.
<body> <header> <main> <article> <h1> <footer> <footer> <body> <header> <main> <article> <h1> <main> <footer> <footer>
The hgroup element was removed from the W3C specification, explaining this by the lack of implementations in browsers, weak usage examples and potential problems. Instead, recommend the usual header and paragraph for the subtitle. In the WHATWG version, the hgroup element is in place - once added, then what to remove.
<article> <header> <h1></h1> <p></p> </header> <p></p> </article>
The W3C specification also provides advanced examples, recommendations for use and develops the semantics of elements. HTML 5 explains the importance of heading levels, recommends figcaption instead of the title attribute for images, explains how to use alt, deprecates, but allows tables for layout, if there is role = "presentation" and so on.
You probably already understood that I like the W3C version more. A strong link with accessibility specifications, more examples and a recent move to the GitHab are very impressive. In my opinion, WHATWG just has other specifications: DOM, Canvas, Fetch, URLs, and many others.
Is it bad that we have two specifications instead of one? Yes. So why not combine them into one? Mmm, this is unlikely: too different approaches to development. But you know, everything is not so bad: these are just two discussion sites with their own rules, where representatives of all browsers, committees and groups come to somehow develop the web. And you come - all on Github.
What specs to believe? Blindly - not one, be guided by implementations in browsers and by practical value. If you do not know about it, does not mean that it does not exist. Choose the spec that you like best and contact it more often - they are written for you.
Questions can be asked here .
Source: https://habr.com/ru/post/339854/
All Articles