Center-align the text in a <p> element:
The textAlign property sets or returns the horizontal alignment of text in a block level element.
The textAlign property is supported in all major browsers.
Return the textAlign property:
Set the textAlign property:
Value | Description |
---|---|
left | Aligns the text to the left. This is default |
right | Aligns the text to the right |
center | Centers the text |
justify | The text is justified |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Default Value: | left |
---|---|
Return Value: | A String, representing the horizontal alignment of text within the element |
CSS Version | CSS1 |
Return the text alignment of a <p> element:
CSS tutorial: CSS Text
CSS reference: text-align property