Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I encountered a peculiar CSS formatting problem when I changed a <div id="header"> block to HTML5's <header> block. Basically, I want links within the <header> block to be of a certain colour and to not get any decoration.

The relevant HTML and CSS codes look as follows:

<!-- HTML5 code -->
<header>
    <h1>
        <a href="#">Link text</a>
    </h1>
</header>

/* CSS code */
header a {
    color: black;
    text-decoration: none;
}

The output I see (using Firefox 20.0 with Ubuntu 12.04) is as if the CSS code fragment above does not exist.

Adding something like class="hdr" to the anchor block and changing the CSS rule to a.hdr works. Changing back to <div id="header"> and #header a also works. Still, I don't see why just using <header> and a corresponding rule fails, and it strikes me as the "correct" approach.

An initial search for a solution led me, among other links, to this link (I had the <h1> block nested within the <a> block, initially), but using a <div> wrapper didn't work either.

share|improve this question
Works for me in Chrome. Can't look at FF now (new system I'm building) but I'm sure it works there, too. – Rob 16 hours ago
1  
This may be a specificity issue. What CSS code are you using to style your other anchor links? – Blazemonger 15 hours ago
Have you checked in the Inspector, to see if the styles really aren't being applied, or if they're just being overridden by something more specific? – crimson_penguin 13 hours ago

migrated from webmasters.stackexchange.com 16 hours ago

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.