0

I'm trying to make a mobile version of my site. Here is the code for the "banner":

<center>
    <div id="banner">
        <a href="./"><img src="graphics/banner.png" /></a>
    </div>
</center>

And using this CSS:

#banner img a {
    background-color: #ccc;
    border-bottom: 1px solid #666;
    color: #222;
    display: block;
    font-size: 20px;
    font-weight: bold;
    padding: 10px 0;
    text-align: center;
    text-decoration: none;
}

When I try it like that it won't work. Everything that was written apparently gets ignored, but if I remove the a, it works normal. But I need it to do that just if the <img> is surrounded by <a>. Why it won't work?

1
  • so i guess <center> is supported on mobile? Commented Dec 30, 2010 at 5:36

2 Answers 2

1

#banner img a means "An a element contained in an img element contained in an element with the id *banner".

You want: #banner a img if you want to select the img element.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks very much! That's what I mean :)
1

I think that you want to have a comma between the HTML elements you want to apply the style to. Try #banner img, a{ ... } instead.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.