FAQ: Learn HTML - Common HTML Elements - Preparing for HTML

This community-built FAQ covers the “Preparing for HTML” exercise in Codecademy’s lessons on HTML.

Here are the most popular community questions on the exercise Preparing for HTML:

Join the Discussion. We Want to Hear From You!

Have a new question or can answer someone else’s? Reply (reply) to an existing thread!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources about HTML in general? Go here!

Want to take the conversation in a totally different direction? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account, billing, Pro, or Pro Intensive? Reach out to our support team!

None of the above? Find out where to ask other questions here!

Other FAQs

The following are links to additional questions that our community has asked about this exercise:

  • This list will contain other frequently asked questions that aren’t quite as popular as the ones above.
  • Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.
  • This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!

Not seeing your question? It may still have been asked before – try searching for it by clicking the spyglass icon (search) in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post (reply).

1 Like

2 posts were split to a new topic: What does “document type” mean?

4 posts were split to a new topic: Why is “DOCTYPE” uppercase but “html” lower?

Can <!DOCTYPE html> be <!DOCTYPE html /> or is that a no-no?

Look up the doctype for XHTML and go by that. If it doesn’t have a self closing tag, then it would qualify as a ‘no-no’.

It’s fair to assume that XML syntax would not come into play until the doctype is declared, so the reasonable assumption would be that no space, and/or slash would be recognized by the user agent.

In the lecture it says

In the future, however, a new standard will override HTML5. To make sure your document is forever interpreted correctly, always include <!DOCTYPE html> at the very beginning of your HTML documents.

So why don’t I write <!DOCTYPE html5 or something like that? Won’t future things, like HTML6 use “html” as well?

1 Like

HTML is a living language which will continue to evolve into newer iterations. The latest recommendations will always be the de facto for newer browser versions. That means we never have to change the doctype again. It will always be,

<!DOCTYPE html>

or whichever variation of that your style guide recommends.

1 Like

Thanks for the fast response.
My train of thought was something like: What if
in future iterations of html no longer means line breaks. Then my code would no longer work. But I guess people wouldn’t just change currently already used syntax, but rather invent new ones.

1 Like

That has always been the case. It’s known as backward compatibility.

There are some exceptions, such that elements and attributes can eventually become deprecated or obsolete, preventing the document from being validated. It won’t have a detrimental effect, though, as the browser will simply ignore it. HTML is rendered as best it can be by any browser.

1 Like

What does it mean to have a new version of HTML? Could the tags/syntax potentially change in future, and we’d need to learn what’s new in, say, HTML7 when that comes around? Or is it some invisible back-end change more to do with how browsers interpret HTML maybe?

Welcome, @arc7160479821,

Good question. Have no fear of being made to learn a new language. Everything we learned in HTML 4 is still valid, save a small handful of obsolete or deprecated tags and attributes.

HTML is a living language, expected to evolve over time in a gradual way that gracefully degrades when exposed to browsers that don’t recognize new tags or attributes. The new stuff will not break old browsers. Conversely, new browsers can handle the old markup as well or better than old browsers.

It traces back to HTML 4.01 which is essentially the base recommendation upon which everything else is built; well, that and XML which forms the basis of XHTML, a stricter, more extensible form of HTML 4.

With the advent of next generation markup specifications that delve deeper into the document and its transmission, vendors were forced to upgrade their browsers to support the new specs. Truth be known, the bulk of the vendors were the driving force of the many recommendations to be adopted by W3C. Look up WHATWG to get the back story.

The newest iteration (at the time) would take the name HTML5, as opposed to becoming version 5. We no longer apply version numbers to the living language, only expand on the type of support given to ANY HTML that is given to a browser, new or old.

No matter what we name it, there is no getting away from what it is… HTML. Same old same old.

1 Like

How does one access an older version of HTML? What would the input be? What would be the reason for using an older version if they’re still accessible? (I’m guessing for project-purposes)

HTML5 marks the inception of the living language while browsers, in conforming with long held standards and recommendations are backwards compatible and will render any previous version as though it is HTML5. This could lead to problems if there are obsolete tags that don’t render correctly, but that is the worst that can happen.

We also get around running older versions of HTML by making sure we include a namespace referral in the document type declaration (the DTD). The browser can then retrieve the specs from the URL it contains. That won’t be complicated since all the DTDs can be found on the W3C site, as well all over the web in older tutorials and articles.

HTML5 is the first iteration that does not need a namespace declaration. The browser has it built in. We don’t even need to declare content type unless we are going to serve XML. The majority of webpages on the internet are text/html, the default of HTML5.

On the face of it, when served as text/html we are following the recommendations of HTML 4.01 with a few extra bits (well, quite a lot, actually) thrown into the mix by the living language. Take an old HTML 4.01 document and swap out the DTD:

<!DOCTYPE html>
<html lang="en">
  <head>
    <charset="UTF-8">  <!-- new to HTML5, as I recall -->
    <title>Sample Document</title>
  </head>
  <body>

  </body>
</html>

That is the basic boilerplate of an HTML5 document.

Once you swap out the DTD, open the validator and select the tab that lets you paste in your code. Check both show original and verbose warnings and click Validate.

The results should be not that overwhelming and if the HTML 4.01 was valid for that DTD, there won’t be very much to revise to make it valid HTML5. This would be good practice, to be sure.

Now for XHTML 1.0 to validate under the HTML5 DTD, the code will still have to conform to the XHTML spec, and will need a content type declaration for text/xml-application if being served as XML. If you dig around on some older sites you may find an XHTML page you can run this experiment on. Be sure it validates as XHTML, then swap out the DTD and validate it again. Any major surprises?