HTML and CSS Reference
In-Depth Information
Text alignment
To control the alignment of text within a container, you specify the text-align attribute. The
text-align attribute supports the values outlined in Table 4-1.
TABLE 4-1 Supported values for text-align
Aligns text to the right side of the parent container
Aligns text to the left side of the parent container
Aligns text to the horizontal center of the parent container
Stretches text horizontally to fill the full width of the parent container
The following code sample demonstrates the use of the text-align attribute, and Figure 4-5
displays the results within the boundaries of a defined div element.
p {
text-align: center;
FIGURE 4-5 The text-align attribute used to position text in the center of a div element
Text indentation
Text indentation is configured using the text-indent attribute. The text-indent attribute
accepts an integer value to indicate how much to indent. The following code sample
illustrates how to indent the text from the left border of the parent div element. Figure 4-6
shows the results of this code.
p {
text-indent: 50px;
FIGURE 4-6 Text indented using the text-indent attribute
Search WWH ::

Custom Search