[parent] * { rule }
Style any tag within the given parent.
h2 * { color: steelblue; }
<h2>
<span> # apply
<a> # apply
<a> # apply
[parent] selector1 ~ selector2 { rule }
Style selector2 if any sibling matching selector1 is found on the same-level.
div h2 ~ p { margin-top: 10px; }
<div>
<p> # not apply
<h2> # this element's existance trigger the rule
<p> # apply
<p> # apply
<div>
<p> # not apply
<div>
<p> # not apply
[parent] selector1 + selector2 { rule }
Style selector2 if it immediately follows selector1 in a same-level sibling relationship
div h2 + p { margin-top: 10px; }
<div>
<p> # not apply
<h2> # this element's existance trigger the rule
<p> # apply
<p> # not apply
<div>
<p> # not apply
<div>
<p> # not apply
#id + .class
)div ~ p + a
)
.main { width: 960px; }
aside ~ .main { width: 550px; }
.main .brand-details ~ .collection .title { font-weight: bold; }
Read: Whenever the class "branding-details" within the class "main" is on the page, set the font-weight of class "tile" within parent "collection" (which is on the same sibling level as "branding-details") to bold.
h2 + h4 { margin-top: 40px; }
selector1 > selector2 { rule }
Style selector2 only when it appears as a child directly under selector1.
p > a { font-weight: bold; }
<div>
<p>
<a> # apply
<p>
<span>
<a> # not apply
aside > * { display: block; width: 100%; }
ul { list-style-type: none; }
ul > li { display: inline-block; width: 150px; font-weight: bold; }
ul li li { color: #BADA55; }
Advantage: The second-level <li>
tags don't need to have their styles all re-written.
selector1:before { rule }
selector1:after { rule }
Create a new DOM element, that appears either before or after, which can be styled independently of selector1.
<span class="error">Incorrect Password</span>
.error { color: red; position: relative; }
.error:before { content: 'x'; position: absolute; top: 5px;
left: -45px; background-color: red; color: #fff;
border-radius: 20px; height: 40px; width: 40px; }
content
property is mandatory.<form>
input.required:before { content: '*'; color: red; position: relative;
left: -10px; }
Side Note: in CSS3 this would simply be input:required:before
.
[attribute] { rule } // Match any tag with the attribute
selector1[attribute] { rule } // Match selector1 with the attribute
[attribute="value"] { rule } // Attribute equals value
[attribute^="value"] { rule } // Attribute starts with value
[attribute*="value"] { rule } // Attribute contains value
[attribute$="value"] { rule } // Attribute ends with value
a[target="_blank"]:after { content: ""; height: 20px; width: 30px;
background: transparent url(new-tab.png) no-repeat;
display: block; margin: auto 5px; }
<span data-title="Some Definition">Deuce Definition</span>
*[data-title] { position: relative; cursor: pointer; }
*[data-title]:hover:after { position: absolute;
content: attr(data-title); display: block; right: -250px;
width: 200px; top: -25px; background-color: #E9EDB7; }
http://developer.mozilla.org