CSS3 Wildcard Selectors

Selecting styles are very similar to how jQuery selectors work.

If we have the classes box-1, box-2, and so on and I want them to use the same border style, we could target them like this:

div[class*='box'], div[class^='box']
{
border: 1px solid #000;
}

CSS attribute selectors:

  • * – will match any part of the attribute value to the given string
  • ^ – will match if the attribute begins with the given string (think class prefixes)
  • $ – matches if the attribute ends with the given string

Source: SitePoint

perm_identityAli Jaffar

schedule

visibility580 reads

labelMarked:

Did you enjoy this post?  


menu