2022.2

Table Of Contents
thefly(inPreviewmodeandinoutput)willlookexactlythesameasthefirstone.Alternatingrowcol-
ors,forexample,indynamicallyaddedrowscanonlybedoneviaCSS.Howtodothisisdescribed
below.
AnothergoodreasontopreferstylesheetsoverlocalformattingforDynamicTables,isthattheoutput
fromaDynamicTableiscreatedslightlyfasterwhenit'sstyledviaCascadingStyleSheetsthanwhen
it'sstyledwithlocalformatting.
Howtousestylesheetsisexplainedinanothertopic;see"StylingtemplateswithCSSfiles"on
page672.
Notethattomakeastyleruleapplytoaspecifictable,roworcell,youhavetoaddanIDorclassto
thattable,roworcell.
Astylesheetcontainsabunchofstylerulesfordifferentelements,thatareidentifiedviaaCSS
selector.Thiscanbetheelement'sHTMLtag(withoutanglebrackets),anattribute,itsID,oraclass.
WhenusedasaCSSselector,theHTMLtagforatableistable.Forarow,itistrandforacell,td.A
stylerulethatusesoneofthese,however,wouldapplytoalltables,rows,orcells.Foraruletobe
morespecificyouneedtoaddanID(forauniqueelement)oraclass(forasetofsimilarelements)to
thetable,roworcell,andusethatasthestylerule'sselector.
Adding an ID or class to a table, row or cell
BeforeyoucanaddanIDorclasstoatable,roworcell,youhavetoselectthattable,roworcell(see
"Selectingatable,roworcell"onpage689).Afterselectingthecell,rowortable,typetheIDorclassin
therespectivefieldontheAttributespane.
InCSS,refertothetable,roworcellwith#ID(whereIDshouldbereplacedwiththeactualID)orwith
.class(whereclassshouldbereplacedwiththeactualclass).
Styling the first, last and nth rows
TheCSSpseudo-classes:first-child,:last-childand:nth-child()areveryusefulforstyl-
ingtablerows,especiallyinDynamicTables.
ACSSpseudo-classfollowsaselectortospecifyaspecialstateofthatselector.Italwaysstartswitha
colon.
Thepseudo-classes:first-child,:last-childand:nth-child()selectanelementonlyifit
isthefirst,lastornthchildelementrespectively.(InHTMLandCSS,thewordchildreferstoanele-
mentinsideanotherelement.)
ThefollowingCSSstyleruleselectsthetablerow(tr)thatcomesfirst(:first-child)initsparent(which
naturallyisatable),andcolorsitsbackgroundred:
Page 691