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
brandonlind2
7,823 Pointshow do you properly used text-align: justify; ? I think I might be trying to use it wrong
I'm trying to center a section with text-align: center; then styling a p tag with text-align: justify; with a margin of 15% to keep it centered, however its not working.
section { max-width: 100%;
margin: auto;
padding: 0;
text-align: center;
}
section p { max-width: 100%
margin: 0 15%;
text-align: justify;}```
ok ty sorry here's the code
Jeff Kinley
21,207 PointsI agree kinda need to see some code to be able to help.
Lauri Neuding
13,525 PointsTry padding the p text. Margin adds to the outside of the div and padding works on the inside.
5 Answers
tomasvukasovic
24,022 PointsI know this is not a real answer but try avoiding the usage of justify text, it creates a lot of rivers in the paragraphs and messes up with the design. Could you attach part of the code so I can check it out and see if there is a syntax error?
Irina Blumenfeld
9,198 PointsSince there is no code, I'm not sure of exact answer. Here's a complete guide on centering anything in CSS: https://css-tricks.com/centering-css-complete-guide/
MUZ140970 Shaune Muringani
11,962 Pointsi agree with all other guys as long as we do not have the code for the visuals its tricky to helpm you out but basically text-align: justfiy works well when you have text in a div container like the footer and you want the text to fit in well (justified) within the container equally spaced from all angles....guess that makes sense
Stefan Claudiu Tiulea
7,110 PointsI would center the text by adding the paragraph with text-align: justify the in a div and center the div.
Kim Gee
3,841 PointsHave you tried the css position property? .myClass { position: absolute; right: 20px; width: 200px; }
Jacob Mishkin
23,118 PointsJacob Mishkin
23,118 Pointsplease post the CSS you are having difficulty with. that way we can see your issue better.