22 Votes

CSS: "align:center" and "align:right" not working

Question by Guest | Last update on 2021-05-14 | Created on 2016-11-01

I want to align one of my texts centered, another text should appear right aligned on my website.

For this, I have added the following CSS to the corresponding paragraph using the style attribute:

<p style="align:center">Should actually be centered...</p>
<p style="align:right">Should actually be right aligned...</p>

However, this CSS does not show any effect. The text remains unchanged left aligned without any alignment, it seems as if it does not play a role whether those properties are defined or not.

What can I do to align a text in HTML with CSS?

ReplyPositiveNegative
2Best Answer2 Votes

The CSS property you are thinking about is named "text-align".

So, you have to write "text-align" instead of "align" only:

<p style="text-align:center">centered</p>
<p style="text-align:right">right aligned</p>

This should work for you.
2016-11-01 at 13:20

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.