HTML align attribute
align
The purpose of the HTML align attribute is to specify the alignment of data and the justification of text in a cell of a table.
Supported elements
HTML align attribute supports col, colgroup, tbody, td, tfoot, th, thead, tr elements.
Usage of align attribute for any other HTML elements is deprecated. You must use CSS for those.
Syntax
<ElementName align="value" >.....</ElementName>
Where ElementName is any supported element.
Type of value
Type of value of HTML align attribute is predefined.
Values
Name | Description |
---|---|
left | Left align data, left justify text. |
center | Center align data, center justify text. |
right | Right align data, right justify text. |
justify | Double justify text. |
char | If used, text is aligned around a specific character. |
Default value
The default value of HTML align attribute is left.
Supported doctypes
HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.
Example of HTML align attribute with col, colgroup, tbody, td, tfoot, th, thead, tr
<!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=iso-8859-1">
<title>Example of HTML align attribute with col, colgroup, tbody, td, tfoot, th, thead, tr </title>
</head>
<body>
<table border="1">
<colgroup>
<col><col align="char" char=".">
<thead>
<tr><th>Student Code</th><th>% of marks</th></tr>
<tbody>
<tr><td>S001</td><td>86.79</td></tr>
<tr><td>S002</td><td>78.98</td></tr>
<tr><td>S003</td><td>83.59</td></tr>
</tbody>
</table>
</body>
</html>
Result
View this example in a separate browser window
Example of HTML align attribute with col, colgroup, tbody, td, tfoot, th, thead, tr.
Previous: HTML action attribute
Next: HTML alt attribute
Test your Programming skills with w3resource's quiz.
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/html/attributes/html-align-attribute.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics