<th> text compatibility
In the table header, the default alignment for the tag this the center.
Consider the following code:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
background-color: aliceblue;
}
.default_grid {
text-align: left;
width: 600px;
color: white;
}
.default_grid th {
/* text-align: left; */
}
.default_grid .first {
background-color: purple;
}
.default_grid .second {
background-color: orange;
}
</style>
</head>
<body>
<table class="default_grid">
<thead>
<tr>
<th class="first">Test One</th>
<th class="second">Test Two</th>
</tr>
</thead>
</table>
</body>
</html>
In Firefox Internet Explorer 7 (& below), Safari, Chrome, and Opera, the text in <th> aligns to the left. In Internet Explorer 8 and Internet Explorer 9 , the text is centered if this rule is not specified directly in the th> tag (line uncomment # 14).
What is the correct behavior?
+5
2 answers
According to W3C Recommendation for TH ,
TH .
, (?) ?
:
TH.Internet Explorer 7 Firefox, Chrome, Safari Opera text-align ( †) TH
<thead>,<table>,<body>..Internet Explorer 8 TH text-align . TH CSS, .
†. font-weight . TH CSS, .
, , . , font-weight (Internet Explorer 8 ) " " (-Internet Explorer 8+) - ; .
, - , . TH .
+15