Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Ryan Decker
3,451 PointsWhy is my background image disappearing when I add the "no-repeat center" properties?
I have a background image in my header. It displays until I add "no-repeat center" into the CSS.
* {box-sizing:
border-box;
}
body {
margin: 0;
font: 1em/1.2 "Helvetica Neue", Arial, sans-serif;
}
/*-----------Font Sizes-------------*/
h1 {
font-size: 5rem;
margin-bottom: 20px;
padding-bottom: 5px;
display:inline-block;
border-bottom: 2px solid black;
}
h2 {font-size: 2rem;}
/*-----------Header-------------*/
#header {
text-align:center;
padding-top: 100px;
background-image: url('../img/sky.jpg') no-repeat center;
background-size:cover;
padding-bottom: 400px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Pittsburgh</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>
<div id="header">
<h1>PITTSBURGH</h1>
<h2>The Steel City</h2>
</div>
</body>
2 Answers

Chyno Deluxe
16,936 PointsHello Ryan Decker,
You are so close to getting it right. Here's the problem. You CSS is targeting speficially the image itself. By removing '-image' from the declaration you code should work. look below.
#header {
text-align:center;
padding-top: 100px;
background: url('../img/sky.jpg') no-repeat center;
background-size:cover;
padding-bottom: 400px;
}

Sean T. Unwin
28,690 Pointsbackground-image
takes a single parameter with a value of an URL, none
, or inherit
.
If you want to use short-hand, i.e. combining property values, you want to use background
.