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 trialClare Yeadon
5,553 PointsDisplay:
I have no idea what this question is asking nor what I need to put:
/* Complete the challenge by writing CSS below */
header {
text-align: center;
}
.logo {
width: 60px;
margin: auto;
}
.main-list li{
display: inline-block;
}
<!DOCTYPE html>
<html>
<head>
<title>CSS Layout</title>
<link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="page.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<header>
<img class="logo" src="city-logo.svg" alt="An illustration of a building">
<ul class="main-list">
<li><a href="#">Donuts</a></li>
<li><a href="#">Tea</a></li>
<li><a href="#">Coffee</a></li>
</ul>
</header>
</div>
</body>
</html>
2 Answers
Peter Vann
36,427 PointsHi Clare! :)
This:
.main-list,
.main-list li {
display: inline-block;
}
is shorthand for
.main-list {
display: inline-block;
}
.main-list li {
display: inline-block;
}
You need both to complete the challenge(s)
.main-list li {
display: inline-block;
}
is a descendent selector. It is targeting the list items that are children of (meaning nested within) of the ul with the class of "main-list", which lines the list items up side-by-side (horizontally).
This:
.main-list {
display: inline-block;
}
targets the whole ul itself and is what shrinks the list to be only as wide as its content (instead of the default behavior, which would be stretch to fit the width of the parent container).
I hope that helps.
Stay safe and happy coding!
Peter Vann
36,427 PointsThis challenge is about understanding the difference between block and inline-block for the display property.
display: block takes up the whole line (the full width of its container)
display: inline-block "generates a block element that doesn't take up a full line" (only as wide as its content)
This passes all three:
/* Complete the challenge by writing CSS below */
header {
text-align: center;
}
.logo {
display: block;
width: 60px;
margin: auto;
}
.main-list,
.main-list li {
display: inline-block;
}
More info:
https://css-tricks.com/almanac/properties/d/display/
https://www.w3schools.com/cssref/pr_class_display.asp
I hope that helps. Happy coding!
Clare Yeadon
5,553 PointsHello, thank you for your help. Why do you have to put .main-list twice?
Zaid Khan
12,769 PointsZaid Khan
12,769 PointsCan you specify the challenge number?