HTML has been on a wild ride. Sure, HTML started as a mere markup language, but more recently HTML’s put on some major muscle. Now we’ve got a language tuned for building true web applications with local storage, 2D drawing, offline support, sockets and threads, and more. The story of HTML wasn’t always pretty, and it’s full of drama. It has evolved time to time in its existence. Its time of HTML5. If you’ve never had exposure to HTML5 before, these questions might have been tickling your mind.
Q1. How does this work on the old browsers? Like the new doctype, meta, and so on... somehow the older browsers work with this new syntax?
Ans: Yes, through a bit of cleverness and luck. Take the type attributes on the link and script tags; now, it makes sense to get rid of this attribute with HTML5 because CSS and JavaScript are now the standards (and certainly are the default technologies for style and scripting). But as it turns out, the browsers already assumed the defaults of CSS and JavaScript. So the stars aligned and the new markup standard just happens to have been supported in the browser for years. The same is true of the doctype and the meta tag.
Q2. What about the new doctype, it seems too simple now; it doesn’t even have a version or DTD?
Ans: Yes, it does seem a little magical that after years of using complex doctypes we can now just simplify it to “we’re using HTML.” Here’s what happened: HTML used to be based on a standard called SGML, and that standard required both the complex form of the doctype and the DTD. The new standard has moved away from SGML as a way to simplify HTML language and make it more flexible. So, we don’t need the complex form anymore. Further, as we said above, there is some luck here in that almost all browsers just look for HTML in the doctype to ensure they are parsing an HTML document.
Q3. Were you joking about it never changing again? I thought the versioning was really important for browsers. Why not use <!doctype html5>? It’s not like there isn’t going to be an HTML6 too. Right?
Ans: The use of the doctype evolved with browser makers using the doctype to tell their browsers to render things in their own “standards mode.” Now that we have much more of a true standard, the HTML5 doctype tells any browser that this document is standard HTML, be that version 5, 6 or whatever.
Q4. Well, I assume different browsers are going to have different capabilities at any one time. How do I handle that?
Ans: True, especially until HTML5 is 100 percent supported.
Q5. Why does this even matter? I just typed a page in without a doctype and meta tag and it worked just fine. Why do I need to worry if this stuff is totally correct?
Ans: Yes, browsers are great at overlooking small errors in HTML files. But by including the correct doctype and meta tags, you’ll make sure browsers know exactly what you want, rather than having to guess. Plus, for people using older browsers, the new doctype means they’ll use standards mode, which is what you want. Remember, standards mode is a mode where the browser assumes you’re writing HTML that conforms to a standard, so it uses those rules to interpret your page. If you don’t specify a doctype, some browsers may go into “quirks mode” and assume your web page is written for older browsers, when the standard wasn’t quite up to snuff, and may interpret your page incorrectly (or assume it’s just written incorrectly).
Q6. Whatever happened to XHTML? It seems like a few years ago that was the future?
Ans: Yeah it was. Then flexibility won out over strict syntax, and in the process XHTML (XHTML 2, to be precise) died and HTML5 was born to be more accepting of the way people write web pages (and the way browsers render them). That said, don’t worry, because knowing about XHTML is only going to make you a stronger author of HTML5 content (and you’re going to appreciate HTML5 a whole lot more). And by the way, if you really love XML, there’s still a wayto write your HTML5 in strict form. More on that later...
Q7. What is UTF-8?
Ans: UTF-8 is a character coding that has support for many alphabets, including non-western ones. You’ve probably seen other character sets used in the past, but UTF-8 is being promoted as the new standard. And it’s way shorter and easier to remember than previous character encodings.
Very useful article. Hope to get more tips on html 5
ReplyDeletePost a Comment