Without the html tags mentioned in this lesson, in what ways might the browser misinterpret our HTML code?

Question

Without the html tags mentioned in this lesson, in what ways might the browser misinterpret our HTML code?

Answer

The <html> tag is actually an example of an optional tag which means that there are situations in which it can be omitted. Even though omitted optional tags will be inserted into the document by the browser and may not always be required, most developers would say that it is best practice to include these tags. Including optional tags enhances readability, improves cross-browser support, and takes some burden off of the browser.

In short, while the <html> tag can be omitted I do not believe it should be omitted.

48 Likes

Thank you for covering the answers of possible questions, this means a lot to me so I can analyze better the concepts of html.

5 Likes

Thanks for answering that was helpful.

1 Like

thanks so much for answering the question

I understand that it’s best practice to use the tag, but could you list potential situations where lack of using the tag would result in the browser misunderstanding what it was reading or such? I do better with specific examples of why something is. Not just “do this.”

“Including optional tags enhances readability, improves cross-browser support, and takes some burden off of the browser.”

Am I understanding correctly what you were referencing?

2 Likes

Respectfully, I don’t really think this answered the question:

which means there are situations in which it can be omitted

But what about situations in which it can’t? Without a specific example, I won’t know what to avoid or look out for.

1 Like

Hey… I’m curious too, and surprised that this never got answered.

What is an example of a situation in which failure to use tags could cause a problem?

That would depend on where you are within the document. If you are inside the <body/> and just have plain text then it will render to the screen using the default font-face of the system, likely Times or Times New Roman, maybe 16px, black on a white background. In this medium it will just be ordinary text like we’re reading right now.

Try it:

A quick brown fox jumps over the lazy dog.

<html>
<body>
A quick brown fox jumps over the lazy dog.
</body>
</html>

The browser will treat the text as text and use default styles to render it.

Now let’s say we have content (that is tagged/marked up) above this plain text, where do we think it will render on the screen? In the old days it would have been at the top of the window, regardless where we placed it in the markup. If it has no tags, it can’t be placed into normal flow and will render before anything else.

Beyond that, since HTML is not a programming language, there are no severe consequences. The browser will do what it can to render the content we supply it. There is literally nothing that can go wrong, apart from that we might not like what we see.

7 Likes

Hi I have a question. During one of the exercises I was to make a list like the following:

When I jumped to the last line to end the tag it moved directly below as apposed to:

Which is what I believe is the correct way to do it. Would the before mentioned code be normal or would it cause any errors? I didn’t check as I just removed two of the spaces to fall directly below the opening code and ran it with no issues. Reason I ask is because that has sort of been the on-going theme for consistency in my head and from what I have been learning. I could be wrong and if it won’t cause issues, then that is something I would like to remember so my OCD doesn’t get the best of me. Thanks in advance.

do you need help? I can help!

In what way? Please elaborate.

Yeah, I agree. Although I have experience with HTML & CSS already, I’ve learned a ton of additional interesting information from the links to the discussions.

for the mentions on top?