w3resource

CSS Text Align

Text Align

text-align property aligns the text in a particular direction. This property aligns the text, which is stacks of line boxes to the left or right of the inline box.

This table declares all the necessary information regarding text-indent :

Value left, center, right, justify, inherit
initial depending upon the direction of the text, if the direction is 'ltr', aligns 'left' and if direction is 'rtr', aligns 'right'.
Applies to block-level elements, table cells and inline blocks
Inherited yes
Percentages N/A
Media visual
Computed value the percentage as specified or the absolute length

left

Aligns the text to the left of the inline box.

right

Aligns the text to the right of the inline box.

center

Aligns the text to the center of the inline box.

justify

In case of justify, this property specifies that the inline boxes are to be made flush with both sides of the block.

Here is a css file (say text-indent-value.css) having a fixed value of text indentation:

p {
text-align: center;
}

Now if it is applied on an html file (say text-indent-value.html)

HTML Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<title>CSS examples</title>
<link rel="stylesheet" href="text-align.css" type="text/css" />
</head>
<body>
<p class="center">CSS is used widely to define color, font, layout etc of a web document. CSS segregates the content of a web page from the properties and values of elements a web document requires for presentational features of the content of the web document.
</p>
<p class="left">CSS is used widely to define color, font, layout etc of a web document. CSS segregates the content of a web page from the properties and values of elements a web document requires for presentational features of the content of the web document.
</p>
<p class="right">CSS is used widely to define color, font, layout etc of a web document. CSS segregates the content of a web page from the properties and values of elements a web document requires for presentational features of the content of the web document.
</p>
<p class="justify">CSS is used widely to define color, font, layout etc of a web document. CSS segregates the content of a web page from the properties and values of elements a web document requires for presentational features of the content of the web document.
</p>
</body>
</html>

View the example of CSS text align in a separate browser window.

Previous: User Interface - Cursor: wait
Next: CSS Tutorials



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/css/text/text-align.php