HTML | DOM Style textAlign Property
The DOM style textAlign property is pretty much similar to the text-align property in the CSS, it sets the alignment for the inner content of a block element.
We can use textAlign in two different ways, one to set the alignment, and the other to get the current alignment.
- Get the value from the current DOM object.
- Set the value of the current DOM object.
object.style.textAlign = "left | right | center | justify | initial | inherit";
- left: It is the default value. The content gets aligned to the left side.
- right: The content gets aligned to the right side.
- center: This sets the content to the centre, between the left and right edges.
- justify: This introduces additional spaces between the words such that the very first word of the line gets aligned to the left side and the last word to the right.
- inherit: It does not do anything fancy rather it sets the value exactly the same as of its immediate parent.
- Before set alingn property:<
- After set alingn property:
Supported Browsers: The browser supported by HTML | DOM Style textAlign Property are listed below:
- Google Chrome
- Internet Explorer
- Mozilla Firefox
Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML course.