My background wont fit the whole page

Tell us what’s happening:
At the top and bottom i see a little white bar that i want to remove. I’ve searched on internet, but putting my height to 100% doesnt work. Ive tried alot of things but cant seem to work it out

Your code so far

<script src=""></script>
<!DOCTYPE html>
<div id="main">
  <div id="background">
  <h1 id="title">Barack Obama</h1>
  <h2>Former USA President</h2>
  <div id="img-div">
    <img id="image" 
src="" alt="Barack Obama">
    <h3 id="img-caption">Former USA President</h3>
  <p id="tribute-info">Obama's life:</p>
     <li><strong> 1961-</strong> Barack Obama was born on August 4, in Honolulu Hawaii  </li>
     <li><strong> 1979-</strong> Obama went to the Occidental College in Los Angeles. </li>
     <li><strong> 1981-</strong> Obama made his first public speech. He transferred to Columbia University to major in political science.</li>
     <li><strong> 1983-</strong> Obama graduated from Columbia University with a Bachelor of Arts degree, magna cum laude. </li>
     <li><strong> 1988-</strong> Obama began to study at Harvard Law School.</li>
     <li><strong> 1990-</strong> On February 5, Obama became the first black president of the Harvard Law Review.</li>
     <li><strong> 1991-</strong> Obama graduated Harvard with his law degree and began work on his book Dreams of My Father.</li>
     <li><strong> 1996-</strong> Obama was elected to the Illinois Senate.</li>
     <li><strong> 2005-</strong> On January 5, Obama was sworn in as a U.S. Senator </li> 
     <li><strong> 2009-</strong> On January 20, Obama was sworn in as the 44th President of the United States. </li>
     <li><strong> 2017-</strong> January 20th marked Obama's last day in the office. </li> 

    <a id="tribute-link" href="" target="_blank"> Read More About Obama</a>

#img-caption {
p {
ul { 
max-width: 550px;
  margin: 0 auto 50px auto;
  text-align: left;
  line-height: 1.6;

margin: 0.1px 0;

#background { 
background-size:100% 100%;
background-image: linear-gradient(to right, rgba(255,0,0,0), rgba(255,0,0,1));

Your browser information:

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

Challenge: Build a Tribute Page

Link to the challenge:

1 Like

Hey @Nqek. Can you please share your CodePen URL. It’s easy to check your code there.

1 Like

Hello there.

Some things to note when using CodePen:

  1. CodePen does not expect any content outside the body tags in the HTML box. The body tag is the tag that contains all the elements in the page, it can’t be a child of a div element. Delete the html tags, the body tags and the DOCTYPE declaration - those are all created in the background by codepen itself.
  2. The editors offer the ability to format and analyze your code, providing useful information about forgotten closing tags etc.

If you are still confused with how to use CodePen, please read the official documentation.

Hope this helps

1 Like

Hey @Nqek. There are many problems with your code:

  • Why did you create a div with class background? If you want to add background image that fits the entire screen, you need to add background-image property to your body tag. If you do so, the background will fit the entire screen. So, now onwards, if you want to create backgrounds, don’t add a separate div for that.

  • You don’t need to add the entire HTML tags in CodePen. You only need to enter the code that goes in the body tag in CodePen’s HTML box. If you want to add code that goes in the head tag, click on the settings icon at the top of the HTML box, and then enter it inside “Stuff in HTML” box.

FInal Result:

Happy Coding!

1 Like

thank you both so much :smiley: problem solved