Jump to content

Align-text Left, Right, Center


ckrudelux

Recommended Posts

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

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

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...