Suffii
Suffii

Reputation: 5784

Issue on Targetting A Class which Has One Specific ID

Can you please let me know how I can target an element with a class which has only specific ID?

For example in the following code I need to change the size of only the class which also has the foo ID.

<ul>
    <li class="sam">This is not Target</li>
    <li class="sam">This is not Target</li>
    <li class="sam" id="foo">This is The Target</li>
    <li class="sam">This is not Target</li>
    <li class="sam">This is not Target</li>
</ul>

I already tried this

#foo .sam {color:green}

but it didn't work. I know that is simply possible in css to target the id element but in this scenarios I have to change the class properties only for that specific item.

Upvotes: 0

Views: 26

Answers (1)

James Donnelly
James Donnelly

Reputation: 128791

You need to remove the space:

#foo.sam { color: green }

Upvotes: 2

Related Questions