Tribute Page - Build a Tribute Page

Hello,

One of the tests when running the code on the Tribute Page project is not passing and I can’t figure it out, was wondering if someone could point me in the right direction?

I basically need to centre the image within its parent. I have taken the parent to be the img-div wrapped around the image and have applied CSS (using flexbox) to that parent to centralise its contents.

I’m obviously missing something though?

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
  <head>
<meta charset="UTF-8"/>
<link rel="stylesheet" href="styles.css">
<title>Dr. Norman Borlaug</title>
</head>
<body>
  <main id="main">
    <section id="Picture area">
    <h1 id="title">Dr. Norman Borlaug</h1>
    <p>The man who saved a billion lives</p>
   <div id="img-div"> <img src="https://images.squarespace-cdn.com/content/v1/5256f6e4e4b086e2b62842e2/1424503144150-2B8ORZP22DKI9ODNFM9K/image-asset.jpeg?format=2500w" id="image">
     
    <figcaption id="img-caption">Dr. Norman Borlaug, third from the left, trains biologists in Mexico on how to increase wheat yields - part of his life-long war on hunger.</figcaption>
    </div>
    </section>
    <section>
      <h2>Here's a timeline of Dr. Borlaug's life:</h2>
     <div id="tribute-info"> <ul>
        <li><span>1914</span> - Born in Cresco, Iowa</li>
        <li><span>1933</span> - Leaves his family's farm to attend the University of Minnesota, thanks to a Depression era program known as the "National Youth Administration"</li>
        <li><span>1935</span> - Has to stop school and save up more money. Works in the Civilian Conservation Corps, helping starving Americans. "I saw how food changed them", he said. "All of this left scars on me."</li>
        <li><span>1937</span> - Finishes university and takes a job in the US Forestry Service</li>
        <li><span>1938</span> - Marries wife of 69 years Margret Gibson. Gets laid off due to budget cuts. Inspired by Elvin Charles Stakman, he returns to school study under Stakman, who teaches him about breeding pest-resistent plants.</li>
        <li><span>1941</span> - Tries to enroll in the military after the Pearl Harbor attack, but is rejected. Instead, the military asked his lab to work on waterproof glue, DDT to control malaria, disinfectants, and other applied science.</li>
        <li><span>1942</span> - Receives a Ph.D. in Genetics and Plant Pathology</li>
        <li><span>1944</span> - Rejects a 100% salary increase from Dupont, leaves behind his pregnant wife, and flies to Mexico to head a new plant pathology program. Over the next 16 years, his team breeds 6,000 different strains of disease resistent wheat - including different varieties for each major climate on Earth.</li>
        <li><span>1945</span> - Discovers a way to grown wheat twice each season, doubling wheat yields</li>
        <li><span>1953</span> - crosses a short, sturdy dwarf breed of wheat with a high-yeidling American breed, creating a strain that responds well to fertilizer. It goes on to provide 95% of Mexico's wheat.</li>
        <li><span>1962</span> - Visits Delhi and brings his high-yielding strains of wheat to the Indian subcontinent in time to help mitigate mass starvation due to a rapidly expanding population</li>
        <li><span>1970</span> - receives the Nobel Peace Prize</li>
        <li><span>1983</span> - helps seven African countries dramatically increase their maize and sorghum yields</li>
        <li><span>1984</span> - becomes a distinguished professor at Texas A&M University</li>
        <li><span>2005</span> - states "we will have to double the world food supply by 2050." Argues that genetically modified crops are the only way we can meet the demand, as we run out of arable land. Says that GM crops are not inherently dangerous because "we've been genetically modifying plants and animals for a long time. Long before we called it science, people were selecting the best breeds."</li>
        <li><span>2009</span> - dies at the age of 95.</li>
        </ul>
        </div>
        <p>"Borlaug's life and achievement are testimony to the far-reaching contribution that one man's towering intellect, persistence and scientific vision can make to human peace and progress."
 <div>         
-- Indian Prime Minister Manmohan Singh</div></p>
<h3>If you have time, you should read more about this incredible human being on his <a href target="_blank"="https://www.w3schools.com" id="tribute-link">Wikipedia Entry</a></h3>

  </main>
</body>
</html>
/* file: styles.css */
#title{text-align: center;}
p{text-align: center;}
li{padding:10px;}
span {font-weight: bold;}
img{width: 80%;
max-width: 100%;
height: auto;
padding:0 100;
display:block;}
img-caption{width:80%;
max-width: 100%;
}
#img-div{display: flexbox;
justify-content:center;
align-items:center;}
#image{background-color:	#808080;}
body{background-color:black;
color: white;
padding: 100;
}




Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36

Challenge Information:

Tribute Page - Build a Tribute Page

you should use css to create an img selector then enter the required properties with corresponding or required value

1 Like

hello - thank you

I actually did that and selected the parent as I read that those properties should be applied to parent?

1 Like

Pay attention that it is very important to know the type of css selectors cause if you have them wrong they’ll be fault to your code I haven’t reached this part of my curriculum but there should be element selector of img and an id selector of img and another id selector of “image”

img{property: value}
#img{property: value;}
#image{ property: value;}
use the above template on your css with the corresponding properties and values assigned… all tests shall pass

1 Like

I am finding this confusing. From what I have read, I need to apply the ‘center styling’ to the parent element, so I selected its class which is #img-div. I then applied the following to the parent (#img-div):

display: flex;

justify-content:center;

align-items:center;

From what I have read, this should center the child within the parent, but it’s still not passing the test, so not sure…

Hello @coderostro !

Try

removing padding completely from the code

and remove the width: 80%

You may be surprised what happens.

Keep up the good progress and Happy coding!

1 Like

I’m not surprised by what happened, because I had faith in your suggestion. Thank you so much!

1 Like

Thank you for your kind words and faith in my suggestions.

You are very welcome!

Happy to help you move on in your coding journey, @coderostro !

1 Like

Very much appreciated. I am so impressed by this forum. Have a great day!

1 Like

Glad to hear it! I find the forum a great group of people, and @CollegeDropout , is proof that we all do our best to help each other. Learning together!

Have a great day, too!

Yes, it’s really great forum and thanks to you both - really appreciate the help.

2 Likes