Can id attributes only be used on <div> tags?

More like four. There are two with printable text plus newline, and two newlines.

Text - Web APIs | MDN

I tried it without quotes, but I didn’t see any error! why?

Show us your code and we might be better to answer why…

1 Like

That’s it:

1 Like

HTML is raw text so everything is treated as character data. The browser can parse out the attribute value given the surrounding syntax, even when quotes are removed. This is only the case when the page is served as text/html. When served as XML all the soft rules go out the window.

Bottom line, don’t let yourself be in the habit of leaving quotes off the attribute values and it won’t come back to bite you.

3 Likes

What is XML? I know HTML stands for hypertext markup language so I would guess XML is some kind of markup langauge. Am I correct?

XML is the top of the food chain of markup languages. It heralds from SGML which it replaces as the standard bearer. It stands for, Extensible Markup Language and its chief role has been centered around data markup. A spreadsheet can be compared to XML if we consider the column headings being the tags, and everything in that column being marked up with that tag.

SGML is the grandfather of markup languages. It stands for Standard General Markup Language. Pretty well all markup languages trace back to that one.

If you have Media Player or iTunes, the data for those apps is wrapped in XML. Many other applications are also built around the language such as WYSIWYG editors like Dreamweaver, to name but one.

A web page is a form of data composition with a presentation element and scripted behaviors. The most obvious juxtaposition of XML in a web environment is the XHTML language of the late 90s. HTML5 has a flavor that conforms to the strictness of that markup (application/xml) but for the most part we use the HTML 4.0 flavor (text/html).

Bottom line, HTML only exists inside the declared root element and not outside of that, where the DTD lives.

3 Likes

Thank you for responding so quickly!

1 Like

What is node basically ?? since I got confused do we count the new lines as a node ??

Good question, and one to find more reading on. A node is essentially anything that can be isolated, so not only is an element a node, if it can contain text, then the text is also a node.

Try this search and see how W3C interprets a node, and its types.

node site:www.w3.org
1 Like

Wow, THANK YOU so so much for this information!!!

1 Like

Thank you Mia! It was helpful

This is really just the reply of all replies :pray:

2 Likes

Follow up to this lesson. I’m new here and trying my best to make an effort to understand code and dive in and find answers to why we might code a certain way or what’s acceptable and what might not be.

In this lesson why in the instructions do they use:

<div id="intro">
  <h1>Introduction</h1>
</div>

image

But in the lesson it only accepts:

<div id="introduction">
    <h2>About Brown Bears</h2>
    <h3>Species</h3>
    <h3>Features</h3>
  </div>

Any answers to this would be greatly appreciated and hope I made sense of my question.

Thank you. Very much for the feedback.