ckrudelux Posted June 26, 2009 Share Posted June 26, 2009 Okay does someone know how I align text in a <p> with css.example: <p>This is a text to the left[c]but this is centered[/c][r]and this is to the right[/r]</p> Set the text-align to left, right, center and use a span to insert them don't work. Link to comment Share on other sites More sharing options...
ckrudelux Posted June 26, 2009 Author Share Posted June 26, 2009 Okay does someone know how I align text in a <p> with css.example:<p>This is a text to the left[c]but this is centered[/c][r]and this is to the right[/r]</p> Set the text-align to left, right, center and use a span to insert them don't work. Okay I was looking on the forum codes how they did the text to my surprise the text are in div's and not paragraph's.Doesn't the text have to be in a paragraph to get validated? Link to comment Share on other sites More sharing options...
Ingolme Posted June 26, 2009 Share Posted June 26, 2009 A <span> won't work, but any block element, such as <div> or <p> will work. text-align only applies to blocks.In the forum they probably use <div> instead of <p> because <p> has margins on the top and bottom. Link to comment Share on other sites More sharing options...
ckrudelux Posted June 26, 2009 Author Share Posted June 26, 2009 A <span> won't work, but any block element, such as <div> or <p> will work. text-align only applies to blocks.In the forum they probably use <div> instead of <p> because <p> has margins on the top and bottom.Okay but is it allowed to use <div> instead <p> this would do things alot easier? Link to comment Share on other sites More sharing options...
Ingolme Posted June 26, 2009 Share Posted June 26, 2009 Of course it's allowed. And it would even be the better solution if the text you're centering isn't actually a paragraph.A <div> has neutral semantic value, it's never wrong to use it, however it's always preferrable to use an element that gives a meaning to the content it contains. Link to comment Share on other sites More sharing options...
ckrudelux Posted June 26, 2009 Author Share Posted June 26, 2009 Of course it's allowed. And it would even be the better solution if the text you're centering isn't actually a paragraph.A <div> has neutral semantic value, it's never wrong to use it, however it's always preferrable to use an element that gives a meaning to the content it contains.Yey There is always something new to learn. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.