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

Centered

I am trying to put my text and the images in the center of the page just like in the video "Working with Grids" and it doesn't work. I am using the same code as in the video <body> <div class="container"> </div> </body>. I also have placed the link in the "head" tag for the grid: <link rel="stylesheet" href="css/grid.css" type="text.css" media="screen>. And also I indented my text. Can anyone tell me what I did wrong?

12 Answers

Guys, I used inside the div putting style too, text-align: center and it works. Thank you for your support. I learned some stuff!

use a site like codepen.io to show your work... then we will help you.

Are you using the

text-align: center

property for it?

I put code in my video also, but it went away.

https://gist.github.com/anonymous/7518200

There is a link to my work, it's the html and the grid.css. I also have the normalize.css bu I saw there is only one section to put a css file so I put just the grid. No I haven't used the text-align: center. How can I display what I do just like you did Erik Montes?

First of all, your html format is not correct. In your gist you have the img tag in the head, which should be in the body. Also the media attribute value needs quotes on both sides not just one:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<img src="img/logo.gif" alt="Logo"><!-- Needs to go in the body, not here in head -->
<link rel="stylesheet" href="css/normalize.css" type="text.css" media="screen><!-- needs to be "screen" not "screen -->
<link rel="stylesheet" href="css/grid.css" type="text.css" media="screen> <!-- also needs to be "screen" not "screen -->
</head>

A lot of the times having improper HTML tags and such will cause things to act weird. So try fixing that just to make sure that's not the culprit.

I've added the answer to your gist:

  • you haven't closed your media attribute's value
  • you've used a wrong type attribute in them, too.

try them out and center your text. There is another centering which contains adding margin of 0 & auto to a well-defined width of container.

I closed my media attribute, still doesn't work.

"also we have a tag and a tag. don't include an in ... It's apples and oranges. ;)"

what's an in?

And also is it wrong to use to .css files? It's as directed by treehouse..

I forgot to add Markdown style!

Now It's fixed!

How do I add markdown style?

James Barnett
James Barnett
39,199 Points

Check out this thread on how to type code in the forum for some examples.

in githubt go here

and for Treehouse just click Markdown Cheetsheet

happy to hear that. ;)