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

The class 'impede' does not align to the center after a width property value is assigned.

* {text-align: center;}
.impede {
    font-size: 0.85em; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    background-color: #99A018; 
    width: 200px; 
} 
<p class="impede">some text were written here before, but they seems to be missing now.</p>

note: a universal selector is assigned to text-align to center. only class 'impede' wont center, others are aligned to center,

1 Answer

Is it not centering the text withing the width you give? It's not going to center to the page, only to the width you give. When no width is given, the p tag takes 100% of it's container so therefore has a width of 100% and will center the contents to the container.

If you need to give your p tag a width and center the entire tag in it's container, you need to add margin: 0 auto;

Check out this codepin to see example .

job done! Thanks much Andrew.