2014-09-25 68 views
0

我有两个不同的“”(什么是正确的术语???)ul s,我想选择a标签,这些标签只在第一个标签内。什么是我想要做的CSS选择器?

<div> 
    <ul> 
     <li> 
      <a>Here's what I'm trying to apply a certain style to</a> 
      <ul> 
       <li> 
        <a>Here's what I'm not trying to apply that certain style to</a> 
       </li> 

      </ul> 

     </li> 

    </ul> 
</div> 

所以我知道我不能只是做div ul li a,因为这将包括内部a标签。

+0

看一看:选择列表中的第嵌套子但不是subchilds](http://stackoverflow.com/questions/25887234/select-first-nested-child-in-list-but-not-subchilds/25887335#25887335) – 2014-09-25 20:37:38

回答

3

您需要:

  • 使用儿童组合子
  • 参考div元素

这样的:

div > ul > li > a 
相关问题