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;
- 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.
- 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.
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.
Comments (0)