Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


What am I doing wrong? Code Challenge: Creating Structure. Question 2

It says Add an id of 'featured-cupcake' to the 'div' you just created.




8 Answers

Hello Sarah. It looks like you are declaring the id outside of the div tag instead of inside of it.

It should look like:

<div id='featured-cupcake'></div>

Hope this helps!

Thanks, I copy and pasted your code and I got this answer-Bummer! Did you put the 'id' attribute on the right element?

The answer I provided was pertaining to the correct practices of using the id attribute, if there is a specific code challenge you are trying to answer you will have to apply the correct id that the challenge is asking for.

As long as you declare the correct id attribute inside the div tags, you should get the correct answer. Good luck!

<div id="featured-cupcake">

Your id needs to be declared within your first div tag, and it needs to be surrounded by double quotes.

How do I answer the question correctly? What do you mean correct id attribute? How does one get a correct id attribute? The specific code challenge instructions state,"Add an id of 'featured-cupcake' to the 'div' you just created. Am I correct in thinking that "featured-cupcake" is the id and therefore the correct answer is <div> id='featured-cupcake'></div> ?

The id attribute can be named whatever you want providing it follows javascript naming conventions. So <DIV ID="featured-cupcake"></DIV> should work unless there's are more specifics to the code challenge. Could you type in the exact instructions of the code challenge and the sample code that is there?

Jacob Miranda
Jacob Miranda
19,073 Points

Use double quotes and put the id attribute in the div element.

Correction as long as it follows html naming conventions

Correction as long as it follows html naming conventions

Hi Sarah,

first off this format is wrong



Austen gave you the correct format to write not the exact answer pertaining to the code challenge itself.

So looking at the code challenge it's asking you to add an ID of featured-cupcake to the div that you just created.

Locate that div, it should look something like this:

<h2>Some text here</h2>
<img src="some pic file.here">

Now add the id of "featured cupcake" to that div and you should be fine. =)

Correction as long as it follows html naming conventions

Sorry - I hit update too many times!