Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML

HTML class attribute errors [SOLVED]

Whats wrong with my code???

Add a div around the featured-cupcake element, and give it the classes container and clearfix. Bummer! Your new div is missing a class. It's supposed to have both 'container' and 'clearfix' as classes.

<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>Smells Like Bakin' Cupcake Company</title>
  <link rel="stylesheet" href="css/normalize.css" type="text/css" media="screen">
</head>

<body>
  <div class="container" class="clearfix">
  <div id="featured-cupcake">

    <h2>Cupcake of the Week</h2>
    <img src="img/featured-cupcake.jpg">
    </div>
    </div>
</body>
</html>
Shen JIE LIN
Shen JIE LIN
10,612 Points

Hi, Aurelian

Try the code below, and see if it works for you. If not let me know.

<!DOCTYPE HTML>
<html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
      <title>Smells Like Bakin' Cupcake Company</title>
      <link rel="stylesheet" href="css/normalize.css" type="text/css" media="screen">
    </head>

    <body>
      <div class="container clearfix">
          <div id="featured-cupcake">
                <h2>Cupcake of the Week</h2>
                <img src="img/featured-cupcake.jpg">
            </div>
        </div>
    </body>
</html>

Shen

it did work, but is that me or that question is set bad?

Shen JIE LIN, if you want to receive credit for helping out, you can add your response as an answer at the bottom of the page.

Shen JIE LIN
Shen JIE LIN
10,612 Points

Hi, Aurelian

Since it did work then I'll go ahead and explain the problem in your coding.

pay special attention to this line in your code.

<div class="container" class="clearfix">

Note how you used class attribute twice, when you wish to denote two different class to the same div or any other HTML elements, the proper way is to simply separate them with a space as the following

<div class="container clearfix">

I hope this explanation helps you, and if you understood please rate best answer, if not then ask any questions you like and I'll try my best to answer you. :)

Hey Dustin Matlock I just saw your posting, I actually don't know how to add my response as an answer, I thought simply commenting below the posting, and have the poster rate my answer as best answer is good enough?

Shen

aaa so no need to write class twice ? insted of that just separate it with a space? wow i didnt know that , its good that i camed back so see all the undone HTML challenges i did time ago . Im going throw HTML courses and see if i an do stuff i coudnt do then .Thank you ;:)

1 Answer

Shen JIE LIN
Shen JIE LIN
10,612 Points

Hi, Aurelian

Try the code below, and see if it works for you. If not let me know.

<!DOCTYPE HTML>
<html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
      <title>Smells Like Bakin' Cupcake Company</title>
      <link rel="stylesheet" href="css/normalize.css" type="text/css" media="screen">
    </head>

    <body>
      <div class="container clearfix">
          <div id="featured-cupcake">
                <h2>Cupcake of the Week</h2>
                <img src="img/featured-cupcake.jpg">
            </div>
        </div>
    </body>
</html>

Shen

Shen JIE LIN
Shen JIE LIN
10,612 Points

AHHHHH, this is how you post answers LOL. okay, thanks Dustin Matlock

When you post answer, people can up vote it or down vote it depending if it was useful and as a best answer is for people that if they look for it , they will see it and know its right . bdw how should i name this so if somebody ever runs in the same problem could find that easy? maybe question that its asked ? this " Add a div around the featured-cupcake element, and give it the classes container and clearfix. " so if somebody paste it this will pop up ?

Shen JIE LIN
Shen JIE LIN
10,612 Points

that is hard to say since when people is having problems with their code sometimes they do not necessarily know where the problems occur, I guess changing the name to something like "HTML class attribute errors" would increase search chances.

done ! Hope it helps other too :)