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 Take a Mobile-First Approach

CSS value wont center text

Hello, I am having trouble with the center text value. Can anyone see what I did wrong?

      <a href="index.html" id="logo">
          <h1>Luke Dier</h1> 
          <h2>Adventurer</h2> 
      </a>```


```#logo { 
  text-align: center; 
  margin: 0;}```

1 Answer

Hi.

You can try adding a div tag here and set a height and width for it. For example.

<style>
        div {
            width: 100%;
            height: 100px;
        }

        #atag {
            text-align: center;
        }
</style>

<div>
             <a href="#" id="atag">
                 <h1>h1</h1>
                 <h2>h2</h2>
             </a>   
</div>

Hope this helps. :)

If setting a width margin:0 auto; also works