Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.

Eric Flowers
Eric Flowers
9,472 Points

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

Eric Flowers
Eric Flowers
9,472 Points

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