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

Luqman Shah
Luqman Shah
3,016 Points

Padding/Margin error with p element.

So I'm trying to have my intro text below my header in the center of the page, which I've succeeded with, but I can't seem to figure out how to make the text only take up minimal space while being in the center, not the whole width of the browser.

code-html: <div class="intro" id="#About"> <p>Welcome to The Food Source, here we talk about what's going on in the food world, what folks are talking about, and what's new. If you love food, then look no farther and jump right in, we've got articles, recipes, and more. Thank you for visiting out website, you'll feel right at home.<p> <a href="#More">Find Out More</a> </div>

code-css: .intro { text-align: center; line-height: 1.6; font-size: 30px; margin-top: 20px; margin-left: 10px; margin-right: 10px;

}

What am I doing wrong?

Cynthia Norwood
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Cynthia Norwood
Front End Web Development Techdegree Graduate 15,214 Points

I believe padding would help. .intro { padding-left: 50px; padding-right: 50px; text-align: center; line-height: 1.6; font-size: 30px; margin-top: 20px; margin-left: 10px; margin-right: 10px; } Or you can just say padding: 50px; or 70px;

Hi Luqman, I would suggest you read more into inline, block and inline block elements. Paragraph elements by default are block level elements, so they will take the full width of the browser.

Try adding a "display: block", "display: inline-block" and "display: inline" to some elements in your CSS to see how these different display properties work.

It may help visually to place a background color on the elements to see the exact changes.