Jump to content

Align-text Left, Right, Center


ckrudelux
 Share

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? Edited by ckrudelux
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...