- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set Text alignment in HTML?
To set text alignment in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property text-align for the center, left and right alignment. HTML5 do not support the align attribute of the <p> tag, so the CSS style is used to set text alignment.
Just keep in mind, the usage of style attribute overrides any style set globally. It will override any style set in the HTML <style> tag or external style sheet.
Example
You can try to run the following code to set text alignment in HTML
<!DOCTYPE html> <html> <head> <title>HTML Document</title> </head> <body> <h1>Tutorial</h1> <p style="text-align:center;">Learn for free</p> </body> </html>
- Related Articles
- How to set alignment to text in text flow layout?
- How to set Heading alignment in HTML?
- How to set the text alignment of Text using FabricJS?
- Set Text Alignment using CSS
- How to set the text alignment in IText using FabricJS?
- Set Text Alignment Working with CSS
- How to set the horizontal alignment of text with JavaScript?
- Java Program to set alignment for text in JLabel
- How to set the alignment of text in a Textbox using FabricJS?
- How do we set the alignment according to surrounding elements in HTML?
- How to set text direction in HTML?
- How to set text font family in HTML?
- How do we set text font in HTML?
- Text alignment in a Matplotlib legend
- How to set vertical alignment for a component in Java?

Advertisements