0

For this code

<div id="dogs" class="content">hello</div> <div id="frogs" class="content">hello</div> <div id="hogs" class="content">hello</div> <div id="logs" class="content">hello</div> 

How can I select the class content from the element that has the id dogs?

1
  • Why can't you just use #dogs? There shouldn't be any other element with an ID of "dogs", since IDs must be unique.. Commented Feb 21, 2012 at 0:39

1 Answer 1

2

You can try this:

.content#dogs { font: bold 28px sans-serif; color: #800000; }
<div id="dogs" class="content">hello</div> <div id="frogs" class="content">hello</div> <div id="hogs" class="content">hello</div> <div id="logs" class="content">hello</div>

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

1 Comment

Thanks, just out of curiosity is .content#dogs equivalent to #dogs.content?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.