2010-09-16 3 views
13

कहते हैं के साथ पहली तालिका में पहले टीडी का चयन मेरे पास है:सीएसएस उदाहरण के लिए 3

<div id="container"> 
    <table> 
     <tr> 
      <td></td> 
      <td></td> 
     </tr> 

     <tr> 
      <td></td> 
      <td></td> 
     </tr> 
    </table> 

    <table> 
     <tr> 
      <td></td> 
      <td></td> 
     </tr> 

     <tr> 
      <td></td> 
      <td></td> 
     </tr> 
    </table> 
</div> 

और

td { width:10px; height:10px; } 

मुझे क्या करना चाहते हैं, पहले टीडी शैली लागू है पहली टेबल

मैं अपेक्षा की होगी:

#container table:first-child td:first-child { 
    background: red; 
} 

हालांकि यह काम नहीं करता? कृपया सलाह दें!

उत्तर

32
#container table:first-child tr:first-child td:first-child { background: red; } 

काम करने लगता है।
ध्यान दें कि आईई के तहत, आपको अपने एचटीएमएल में डॉक्टरेट घोषणा की आवश्यकता होगी: पहला बच्चा। http://www.w3schools.com/cssref/sel_firstchild.asp