Explanation for <div id="introduction">?


#1

Hello,

The lesson introduces < div id=" " > for the first time in Learn HTML: Elements and Structure, 3/17 in Text Content Tags.

In the lesson, it is shown in this order: < h1 > The Brown Bear < /h1 > and then < div id=“introduction” > following after.

What does the < div id=“introduction” > mean & what is its purpose on the web browser?

Thank you in advance.


#2

well, if we have two h1 elements:

<h1 id="red">red</h1>
<h1 id="blue">blue</h1>

how would we make the first h1 red, and the second h1 blue? just doing h1 { color: red }, will make them both red (have you already started css?)

selectors allows us to apply us different styling to the same element.

an id has to be unique. Is there no explanation at all in the lesson about id?


#3

No, the lesson just introduces < div > and < span >.
On the instructions, it said to:

Below the < h1 > element that says The Brown Bear, add this opening < div > tag: < div id = “introduction” >.
Add the closing < /div > tag after the < h3 > element that says Features.
Always add two spaces of indentation when you nest elements inside of < div >s.

The result was:
< h1 > The Brown Bear < /h1 >
< div > tag: < div id=“introduction” >

No, I’m a HTML beginner, and did not start with CSS yet!
There was no explanation at all for id yet.
I’m assuming it will explain it later when I hit CSS?

So, from what you’re saying… in your example you want to differentiate the first h1 and second h1 red and blue, and that the id is "unique."
In this case, in my example, for h1 The Brown Bear, the “introduction” is uniquely only to the The Brown Bear? :slight_smile:


#4

no, the the div element. The id belongs to the elements its given to


#6

the div stands fora division within the body, which may include a paragraph. id stands for identification.


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.