Created
December 11, 2012 08:58
-
-
Save kitgrose/4257140 to your computer and use it in GitHub Desktop.
Weird WebKit CSS bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style type="text/css"> | |
tr > * { | |
padding: 1em; | |
} | |
tr:nth-child(even) td { | |
background-color: red; | |
} | |
</style> | |
</head> | |
<body> | |
<table cellpadding="0"> | |
<tr> | |
<th>1</th> | |
<th>2</th> | |
<th>3</th> | |
<th>4</th> | |
</tr> | |
<tr> | |
<td> </td> | |
<td> </td> | |
<td> </td> | |
<td> </td> | |
</tr> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is definitely the weirdest bug I've seen in WebKit. All four cells in the second table row should be red, but only the first two are.
The issue goes away if you remove the
cellpadding
attribute, or if you replace the first row withtd
elements instead ofth
ones. The issue doesn't affectnth-child(odd)
, onlyeven
(the mere existence of anodd
CSS rule—even without any declarations—changes the behaviour). If you try to inspect either of the wrong-coloured elements, they redraw correctly.If you add another row of standard cells, they're also treated as
even
, even though they're now in the third row.