Categories
CSS

CSS: applying style sheets to children tags / using regular expressions with CSS / targeting attributes

ul li a { ..style here applies to a tags inside li which are also inside ul tags…}
p.intro a {…style here applies to all a tags that are inside p tags that are of the class intro…}
div > h1Only h1s that are children of a div tag
h2 + pApplies style to paragraphs that are brothers (share a common parent) with the h2 tag
img[title]Applies style to img tags with the attribute title on it
input[type=”text”]Applies to input text boxes only
a[href=”http://www.cosmofarmer.com”]{ color:red; font-weight:bold; }Applies to the cosmofarmer.com particular link
img[src*=”headshot”]Like a regular expression, for all images that contain headshot somewhere in the src

 

img[alt^=”film”] Same as above, but this time all images where the attribute alt starts with  “film” gets targeted

img[alt$=”film”] Now we are targeting the end of the attribute string

Leave a Reply

Your email address will not be published. Required fields are marked *