13 May 2005

Software: CSS Selectors

Fresh from XSLT, I wanted to address sub-entities in CSS based on a top level element so that I wouldn't have to label every sub-entity with a class or id attribute. CSS selectors to the rescue! So, if I have the following HTML structure:
<table id="ATest">
Then I can select different parts of the structure ...
table#ATest { /* Entire table */ }
table#ATest thead { /* Just the thead portion */ }
table#ATest tbody { /* Just the tbody portion */ }
table#ATest tr { /* All tr sub-entities */ }
table#ATest tbody tr { /* Just the tr entities in the tbody */ }
table#ATest tbody tr:first-child { /* Just the first tr in the tbody */ }
After some testing, I found that IE 6.0 doesn't support the use of the > selector for selecting the child (not descendent) of an entity nor does it support the :first-child pseudo class. Firefox 1.0x does support them, so I can have a different style for the first child of any entity.