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

CSS How to Make a Website CSS: Cascading Style Sheets Center the Wrapper

Yashar Soroosh
Yashar Soroosh
5,617 Points

div

Hi I applied the div on the index file and all the css code on css main file however my images do not get centred. Nothing really changes. What could I be doing wrong?

12 Answers

Rose Hurst
Rose Hurst
5,658 Points

Hi Yashar, Have you double checked the that your syntax is correct in your main.css? Things to look for are missing Curly braces { }, and ; <br>

Another thing to look at is if you used "class" or "id" in your div.

Hi Yashar, have you linked your stylesheet? If so double check the syntax.

<head>
<link rel="stylesheet" type="text/css" href="mainstyles.css"
</head>
Yashar Soroosh
Yashar Soroosh
5,617 Points

I have but I followed the way shown on the video.html<head> <link rel ="stylesheet" href = "css/main.css"></head>

Yashar Soroosh
Yashar Soroosh
5,617 Points

"<head> <link rel ="stylesheet" href = "css/main.css"></head>"

Yashar Soroosh
Yashar Soroosh
5,617 Points

Eric I don't know why but it does not display my code when I try to type it in the text box

Yashar Soroosh
Yashar Soroosh
5,617 Points

Eric I don't know why but it does not display my code when I try to type it in the text box

Yashar Soroosh
Yashar Soroosh
5,617 Points

Eric I don't know why but it does not display my code when I try to type it in the text box

Yashar Soroosh
Yashar Soroosh
5,617 Points

a { text-decoration: none; }

wrapper {

max-width: 940px margin: 0 auto; background: orange; }

It seems correct

If you copied that from your text editor Rose nailed it. You're missing a semicolon after max-width.

Yashar Soroosh
Yashar Soroosh
5,617 Points

Thanks guys it worked. I appreciate your help.

Hi, Yashar, if you have only <div> you must add class in your html document, so it should be <div class="wrapper">your code</div> and in css document you need to edit wrapper to .wrapper

EDIT:// I'm sorry, I didn't see your response, that it has been resolved