Tribute page | Image

Hey! Sorry, another question. This is the last step I need to complete in order to finish this project:

Failed: Your #image should be centered within its parent.

I don’t know what I’m doing wrong. Here is my script:

<div id="img-div">
        <img id="image" src="https://media.vogue.es/photos/5cc7595015d9a3f092e83f50/1:1/w_815,h_815,c_limit/moda_tendencias_voguees_223283395.jpg" alt="Rihanna">
        <figcaption id="img-caption">A beautiful portrait from Rihanna, one of the best singers of the century.</figcaption></div>

And here is the CSS:

#image {
    max-width: 100%;
    display: block;
    border: 3px solid #000;
    display: flex;
    justify-content: center;
}

#img-caption {
    text-align: center;
    color: #333;
    font-family: 'Barlow';
    font-size: 0,7em;
}

Thanks in advance! I’m looking forward to fix this.

1 Like

The parent for your img element is <div id="img-div">.

1 Like

So, I have to make the div centered in order to center the image? with margin auto?

1 Like

Set the margin property to: margin: 0 auto;, and delete:

   display: flex;
    justify-content: center;

You can not have two display properties in one selector to function both properly.

1 Like

It is not centered, and this error still appears:
Your #image should be centered within its parent.

1 Like

Delete:

display: flex;
    justify-content: center;

This way only ‘display: block’ will stay functional.

1 Like

I deleted it but it stills gives me the error message and is not centered. I tried deleting display: block but still the same.

1 Like


It works well. If it doesn’t pass the requirement, then something else is not OK.
Always post the entire html and css code. Often, something else in your code is not correct, but the ‘hint’ continues to repeat the same thing.

1 Like

I added again the display: block and now it’s centered, but it doesn’t pass that error. Here is my full HTML and CSS script:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Rihanna, the best singer</title>
    <link rel="stylesheet" href="styles.css">
    <link href='https://fonts.googleapis.com/css?family=Aboreto' rel='stylesheet'>
    <link href='https://fonts.googleapis.com/css?family=Alex Brush' rel='stylesheet'>
    <link href='https://fonts.googleapis.com/css?family=Barlow' rel='stylesheet'>

    </head>
<body>
    <header>
<h1 id="title">Rihanna</h1>
<h2 id="subtitle">The best singer</h2>
<div id="header"></div>
    </header>
    <main id="main">
    <div id="img-div">
        <img id="image" src="https://media.vogue.es/photos/5cc7595015d9a3f092e83f50/1:1/w_815,h_815,c_limit/moda_tendencias_voguees_223283395.jpg" alt="Rihanna">
        <figcaption id="img-caption">A beautiful portrait from Rihanna, one of the best singers of the century.</figcaption></div>
    <br>
    <div id="divider"></div>
    <br>
    <h3 id="about">About her:</h3>
    <p id="tribute-info"><b>Robyn Rihanna Fenty</b> (born February 20, 1988) is a Barbadian singer, actress, and businesswoman. Born in Saint Michael and raised in Bridgetown, Barbados, Rihanna auditioned for American record producer Evan Rogers who invited her to the United States to record demo tapes. After signing with Def Jam in 2005, she soon gained recognition with the release of her first two studio albums, <i>Music of the Sun </i> (2005) and <i>A Girl Like Me </i> (2006), both of which were influenced by Caribbean music and peaked within the top ten of the US Billboard 200 chart. </p>
<br>
<p id="tribute-info">Rihanna's third album, <i>Good Girl Gone Bad</i>  (2007), incorporated elements of dance-pop and established her status as a sex symbol in the music industry. The chart-topping single <i>"Umbrella"</i> earned Rihanna her first Grammy Award and catapulted her to global stardom. She continued to mix pop, dance, and R&B genres on her next studio albums, <i>Rated R </i> (2009), <i>Loud </i> (2010), <i>Talk That Talk </i> (2011), and <i>Unapologetic </i> (2012), the last of which became her first Billboard 200 number one. The albums spawned a string of chart-topping singles, including "Rude Boy", "Only Girl (In the World)", "What's My Name?", "S&M", "We Found Love", "Where Have You Been" and "Diamonds". Her eighth album, Anti (2016), showcased a new creative control following her departure from Def Jam. It became her second US number one album and featured the chart-topping single "Work". During her musical career, Rihanna has collaborated with many artists, such as Drake, Eminem, Jay-Z, Kanye West, Ne-Yo, and Shakira. </p>    
<p id="more-info">You can get to know more about Rihanna <a href="https://en.wikipedia.org/wiki/Rihanna" id="tribute-link" target="_blank">here</a>.</p>
<br>
</main>
</body>
</html>
#title {
    font-family: 'Aboreto';
    font-size: 6rem;
    text-align: center;
    color: #000;
    margin-bottom: 0;
}

#title:hover {
    color: #8d302b;
    transition: 1.5s;
}

#subtitle {
    font-family: 'Alex Brush';
    font-size: 4rem;
    text-align: center;
    color: #000;
    margin: 0;
}

#image {
    max-width: 100%;
    display: block;
    border: 3px solid #000;
    margin: 0 auto;
}

#img-caption {
    text-align: center;
    color: #333;
    font-family: 'Barlow';
    font-size: 0,7em;
}

#divider {
    border-bottom: solid 2px #000;
    margin: 2px auto;
    width: 1000px;
}
#about {
font-family: 'Aboreto';
font-size: 2rem;
text-align: center;
text-shadow: 2px 1px 2px black;
}

#tribute-info {
    font-family: 'Barlow';
    line-height: 2em;
    color: #000;
    margin: auto;
    padding: 20px 30px;
    font-size: 1.2em;

}

#more-info {
    font-family: 'Barlow';
    line-height: 2em;
    color: #000;
    margin: auto;
    padding: 20px 30px;
    font-size: 1.5em;
    text-align: center;
    text-shadow: 1px 1px 2px black;

}

a:link {
    font-family: 'Barlow';
    line-height: 2em;
    color: #8d302b;
    font-size: 1em;
    text-align: center;   
}

Do you see any mistakes that might cause it to not pass that error?

1 Like

As I said, other things are wrong here. You have duplicated ids:

<p id="tribute-info"> you have it two times. It is not allowed!

The link to the fonts is:

<link href="https://fonts.googleapis.com/css2?family=Alex+Brush&display=swap" rel="stylesheet">
1 Like

Sorry, I didn’t know that! I fixed it. This error still arrives: Your #image should be centered within its parent. I might have to do something with the div? The image is already aligned, i don’t know what else to do :sob:

1 Like

Copy everything to another place.

Restart step.

Paste back.

Try the following:
“Note: Some browser extensions, such as ad-blockers and dark mode extensions can interfere with the tests. If you face issues, we recommend disabling extensions that modify the content or layout of pages, while taking the course.”

1 Like

I tried that and that error still appears :frowning: I’m with Firefox and it never caused any trouble.

1 Like

Your project has passed the fCC test. Something else is bugging here…

1 Like

Oh, that is alright! I’m trying to pass the tribute page exercise. That’s what doesn’t pass.

1 Like

Try this to parent Element

1 Like

Hi! I’ve tried that and it didn’t worked. I disabled all my extensions too

1 Like

The error says “your #image should be center within its parent” meaning the other Id which come before the #image should be style first then follow by the #image that is the logic here.
Try that and revert.

1 Like

The other IDs before the #image happen to be the parent to #image meaning they accommodate #image.

1 Like

It is unobvious issue, but.

The thick border messes with the tests on my end.

Try

delete border property from #image selector

or

reduce size of the border from 3px to 2px or less

1 Like