5. Class Selectors I: CSS


#1


https://www.codecademy.com/courses/learn-html-css/lessons/ids-classes-divs/exercises/class-selectors-i

Hello,

I'm a bit stuck with this exercice. I'm being asked to add a class selector for the class partner, which is defined by a point if I'm not mistaking, while ID selector are defined with hastags.

What is wrong in my below code? Can someone point to me what I am missing?

Many Thanks,

Nathalie


/* Add the ID selector to this CSS rule */

#partner {
  margin: 0 auto;
  position: relative;
  text-align: center;
  top: 25%;
  width: 60%;

/* Add the class selector to this CSS rule */

.partner img {
  position: relative;
  top: 6px;


#2

Hi you didn't close the #partner and the .partner img

#partner {

}

#partner img {

}

#3

Thanks for your quick reply.

Unfortunately that doesn't solve my issue. They are already closed, I just didn't copy paste that part. I apologise.

Also I do not understand why we have two #header-text classes declarations

/* Add the ID selector to this CSS rule */

.header-text {
margin: 0 auto;
position: relative;
text-align: center;
top: 25%;
width: 60%;
}

/* Add the class selector to this CSS rule */

.header-text {
padding: 20px;
text-align: center;
margin: 0 auto;
border-bottom: 1px solid #EEE;
}

.partner img {
position: relative;
top: 6px;
}

If I replace any with a hashtag, I get an error message to not use ids selectors. It's contradictory in my opinion.


#4

I was stuck on the same exercise and the below code is what worked for me. Note that if it says ID it HAS to be a #header-text. Whereas .header-text refers to class. Also, ignore the " before the #, I just added that to stop this text box formatting it.

/* Add the ID selector to this CSS rule */
"#header-text {
margin: 0 auto;
position: relative;
text-align: center;
top: 25%;
width: 60%;

/* Add the class selector to this CSS rule */

.partner {
padding: 20px;
text-align: center;
margin: 0 auto;
border-bottom: 1px solid #EEE;
}"


#5

Thanks whomping!

I copy-pasted ".partner {" for the class selector and it worked brilliantly.

Turned out that I was so focused on the . and # thing that I missed the name header instead of partner.

Thanks again!


#6

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