Web Tools Table Maker3schools TranslateImage CompressorFavicon Icon GeneratorCrop & Resize Image
Apu
Apu June 06, 2023 › #css #HowTo

How to align text in HTML using CSS

By using CSS, you can easily adjust the alignment of text in your HTML documents. To align text or other HTML element using CSS, you can use the text-align property. It has three values - left, center and right.

How to Left Align Text in HTML using CSS#

To left-align text in HTML using CSS, you need to add the following code to your CSS file.

Here are some things to keep in mind while using text-align:left;

  1. By default, text is left-aligned in HTML. So, you only need to use this code in case you want to override any alignment settings.
  2. You can add this code to any selector in your CSS file.

How to Center Align Text in HTML using CSS#

To center-align text in HTML using CSS, you need to add the following code to your CSS file.

If you want to center-align the text within a specific container, you need to set the text-align property on that container.

How to Right Align Text in HTML using CSS#

To right-align text in HTML using CSS, you need to add the following code to your CSS file.

Overall, aligning text in HTML using CSS is a simple task that can make a big difference in the appearance of your website. By using the code examples provided above, you can easily align your text according to your preferences.

save
listen
AI Answer
Write Your Answer
loading
back
View All