I’m trying to get the first article on the page using CSS. I have tried the following:
article:first {
background: blue;
}
and
article:first-child {
background: blue;
}
However neither of these seem to be doing anything.
My HTML markup is as follows (head removed and content ellipsed):
...
<body>
<div id="wrapper">
<header>
<hgroup>
...
</hgroup>
</header>
<article>
...
</article>
<article>
...
</article>
</div>
</body>
I’m also using the latest version of chrome.
What you’re looking for is
#wrapper article:first-of-type, but unfortunately it’s not widely supported yet.You could try
#wrapper header + articlethough, for which support is more widespread.