0
#customers tr.alt td 
{
color:#000000;
background-color:#EAF2D3;
}

#customers is the id of a table. Since I'm new to CSS, is the above method a valid selector? In CSS I have only found element element selectors. But here in the question there are three elements: table tr td. I have not found an example of the three element selector. So does the three element selector exist in CSS?

ASGM
  • 11,051
  • 1
  • 32
  • 53
Maizere Pathak.Nepal
  • 2,383
  • 3
  • 27
  • 41

3 Answers3

2

Yes you can combine as many simple selectors as necessary, and the selector you posted simply styles

any <td> thats within a <tr> with the class="alt" and is within an element with the ID "customers"

http://www.w3.org/TR/css3-selectors/

Adrift
  • 58,167
  • 12
  • 92
  • 90
1

The selector is valid, since the CSS selector syntax allows a descendant selector that “is made up of two or more selectors separated by white space”. This is the case in the CSS 2.1 specification, and CSS3 won’t change this.

Technically, #customers tr.alt td does not not contain three elements but three selectors, though it can only match an element that is part of a structure containing three nested elements.

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
0

Yes this is a valid CSS selector. You can combine as many as you want.

Floremin
  • 3,969
  • 15
  • 20