GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||
GeezerVison is showing developer.mozilla.org — text-align CSS property - CSS | MDN
|
| Initial value | start, or a nameless value that acts as left if direction is ltr, right if direction is rtl if start is not supported by the browser. |
|---|---|
| Applies to | block containers |
| Inherited | yes |
| Computed value | as specified, except for the match-parent value which is calculated against its parent's direction value and results in a computed value of either left or right |
| Animation type | discrete |
text-align =
start |
end |
left |
right |
center |
<string> |
justify |
match-parent |
justify-all
<p class="example">
Integer elementum massa at nulla placerat varius. Suspendisse in libero risus,
in interdum massa. Vestibulum ac leo vitae metus faucibus gravida ac in neque.
Nullam est eros, suscipit sed dictum quis, accumsan a ligula.
</p>
.example {
text-align: start;
border: solid;
}
<p class="example">
Integer elementum massa at nulla placerat varius. Suspendisse in libero risus,
in interdum massa. Vestibulum ac leo vitae metus faucibus gravida ac in neque.
Nullam est eros, suscipit sed dictum quis, accumsan a ligula.
</p>
.example {
text-align: center;
border: solid;
}
<p class="example">
Integer elementum massa at nulla placerat varius. Suspendisse in libero risus,
in interdum massa. Vestibulum ac leo vitae metus faucibus gravida ac in neque.
Nullam est eros, suscipit sed dictum quis, accumsan a ligula.
</p>
.example {
text-align: justify;
border: solid;
}
This example demonstrates the use of text-align on <table> elements:
<caption> is set to right-aligned.<th> elements inherit the left alignment from the text-align: left set on the <thead>, while the third is set to right-aligned.<tbody> element, the first row is set to right-aligned, the second is set to center-aligned, and the third uses the default (left) alignment.<table>
<caption>
Example table
</caption>
<thead>
<tr>
<th>Col 1</th>
<th>Col 2</th>
<th class="right">Col 3</th>
</tr>
</thead>
<tbody>
<tr class="right">
<td>11</td>
<td class="center">12</td>
<td>13</td>
</tr>
<tr class="center">
<td>21</td>
<td>22</td>
<td>23</td>
</tr>
<tr id="r3">
<td class="right">31</td>
<td>32</td>
<td>33</td>
</tr>
</tbody>
</table>
table {
border-collapse: collapse;
border: solid black 1px;
width: 250px;
height: 150px;
}
thead {
text-align: left;
}
td,
th {
border: solid 1px black;
}
.center {
text-align: center;
}
.right,
caption {
text-align: right;
}
| Specification |
|---|
| CSS Logical Properties and Values Module Level 1 # text-align |
| CSS Text Module Level 3 # text-align-property |