Jump to content

first-child problems


Recommended Posts

I am creating a dropdown for a site, but cant seem to get it so only a few of the list items are effected by a certain effect. Here is a much shorter example of what my coding will look like.





<style type="text/css">










<li><a href="#">Coffee</a>


<li><a href="#">fdas</a></li>

<li><a href="#">fdas</a></li>




<li><a href="#">Tea</a></li>

<li><a href="#">Coca Cola</a></li>






I am trying to make it so only Coffee, Tea, and Coca Cola are highlighted. while fdas isn't. Thank you for your time and consideration

Link to comment
Share on other sites

Use classes. Using the first-child attribute is going to affect all first-child elements it can find. Either that or you should use it on the ul:first-child. That way, you only target the first li elements. However, this way, Coca Cola will not be highlighted since Coca Cola is not the first child of ul.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...