Is it possible with CSS and the latest Chrome or Firefox to automatically remove the top margin from the first <h1>
tag, or do I have still have to use jQuery?
You just need h1:first-child { margin-top: 0px; }
DEMO
There's no :first-of-page
selector so no, you can't use CSS for sure. No way in CSS to extract all h1 from a page whatever their parents and preceding siblings and only take the first one.
You need to know a little bit more about your h1 elements.
Examples:
body > header
(or #header in HTML 4.01)h1:first-of-type
is the first one for surebody > nav + section > h1
would select it. Or maybe body > header > nav + section > h1:first-of-type
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With