FAQ: Learn HTML - Intro to HTML - Attributes

id tag? You mean id attribute? This one:

?

if you mean id attribute, then the answer is: no

So, I understand the attributes feature to div tags. Is the only purpose of adding an attribute to div tags to differentiate divs from each other for styling them in CSS?

css does positioning as well, any decent website has a lot of div tags for a good layout

I am following the tutoring class but after I do the changes suggested and click on Run it take a long time to give results is spinning for minutes at every change is very upsetting, this definitely is not acceptable to a person learning anything I do not have the time and patience to do this.

les guillemets sont toujours rouge

A post was split to a new topic: Would this be the correct use of indentation?

Hi all, sorry if this is on the wrong thread- I am new to coding and can’t figure out if I’ve done this in HTML Elements & Structure correctly or not… I have ticks on the left as you can see indicating it is correct but red dots in the centre alerting me to the fact the code is wrong…?
Any advice and how to fix this code is very welcome!

Hey there,

Indeed the red dots show you were there are issues with your code.

So there’s an issue around lines 11 and 12. Let’s try to figure out why, by comparing those with other lines that don’t raise any errors.

<div id="habitat"
</div>

Now let’s take a quick look at another <div> tag that doesn’t raise any errors.

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

You should be able to quickly spot where things went wrong.


Also, if you’re gonna have a div with an id of "habitat", you might want to consider any other tags that might be relevant to that particular div.

For example, I see an <h2> tag with Habitat as content. Would it make sense to have it enclosed between the opening and closing divs with an id of “habitat” ? Are there any others which we might also want in there? If in doubt, take another quick look at the div with an id of “intro”.

If ever in doubt, keep in mind that divs are there to separate your page into sections.

Let’s say we have a menu:

<h1>Our menu</h1>

<div id="pizza">
  <h2>Our Pizzas</h2>
   <ul>
     <li>Margarita</li>
     <li>Pepperoni</li>
     <li>Calzone</li>
   </ul>
</div>

<div id="pasta">
  <h2>Our Pasta</h2>
   <ul>
     <li>Fettuccine with Prosciutto</li>
     <li>Spaghetti alla Carbonara</li>
     <li>Genoese Pesto</li>
   </ul>
</div>

The different divs will separate our page into sections that serve different content, and which make sense to enclose together (for lack of better wording).

Hope this helps, and let me know if you have any questions!

2 Likes

Is it mandatory to write value of attribute with in “”?
id=“value”
or we can write it as
id=value?

without quotation marks is allowed/support since html5, although I prefer to use quotation marks

1 Like

Thankyou. I’ll use quotations.

what is wrong? because my answer is not being accepted?

The Brown Bear

<h2>About Brown Bears</h2>

<h3>Species</h3>

<h3>Features</h3>
<h2>Habitat</h2>

<h3>Countries with Large Brown Bear Populations</h3>

<h3>Countries with Small Brown Bear Populations</h3>
<h2>Media</h2>

Did you add the respective id attribute to the divs? For example: <div id="introduction"> and so on.

Also, check out this guide on how to format your code so that we can see it correctly as text and not displayed as html elements.


Hey hows it going everyone, I am quite stumped at this point I have done everything that is said, Ive made sure my letters arent capitalized however its not going through. I am able to actually use the functions successfully but apparently there are errors.

Wrong thread.
This thread is about the exercise “Attributes”
Your question is about the exercise “Linking to Same Page”. The thread for that exercise is: FAQ: Learn HTML - Common HTML Elements - Linking to Same Page

Anyways, in your screenshot, the ids and hrefs are correct. They are all lowercase as specified.

Step 1 specifies that the text of the list items should be:
"Introduction, Habitat, Media"
You have:
"introduction, habitat, media"

Thank you and I do apologize, on the said activity page it directly linked me to here. Im new so still getting used to things, thanks for your help I have now passed this!

1 Like

so i just got to the attributes section of the lesson, and found out that adding an “id=‘value’”, i was receiving errors, and the errors only stopped when i put a space before the value of the attribute. is this normal or something was up?

It would help to see the markup and the error message. The only time we need a space is in front of the attribute.

<div id="first" class="content">
    ^          ^

Visually is the way I formatted the code acceptable?

I noticed for <div id="introduction"> when I add a closing </div> at the end it gives me an error on line 7.
I’m assuming it’s because there’s already a closing </div> tag on line 7.

My question is, is this correct? Or should I remove the closing </div> tag on line 7 and put it on line 3 or below on line 4?

Divs

Hi,
I think the you have missing out the closing brackets of the opening tag in line 11 and line 16.
I think it should be <div id = “habitat”> and <div id = “media” >.
Thanks