a[data-info~="external"] {
color: red;
}
a[data-info~="image"] {
border: 1px solid black;
}
<div id="container">
<p> Lorem ipsum dolor sit amet, <a title="Some title"
data-info="external" href="http://www.google.com">
consectetur</a> adipisicing elit, sed do <a href="http://
nettuts.com">Nettuts</a> tempor. </p>
<p> Lorem ipsum <a href="http://net.tutsplus.com">
Nettuts+</a> sit amet, consectetur "
<a data-info="external image" href="http://d2o0t5hpnwv
4c1.cloudfront.net/839_git/preview.jpg">Getting Good
with Git</a>" elit, sed do eiusmod tempor. </p>
</div>
input[type=radio]:checked + label {
border: 1px solid red;
}
<form>
<input type="radio" value="Radio Button" name="rad">
<label for="rad"> Radio Button</label>
</form>
.head1:before{
content: url(smiley.gif);
}
.head2:after {
content: url(smiley.gif);
}
<h1 class="head1">This is a heading</h1>
<p>The ::after pseudo-element inserts content
after an element.</p>
<h1 class="head2">This is a heading</h1>
<p><b>Note:</b> IE8 supports the content
property only if a !DOCTYPE is specified.</p>
a:hover {
background-color: yellow;
}
<a href="http://www.ecartstudio.com">
ecartstudio.com</a>
<a href="http://newweb.ecartstudio.org">
newweb.ecartstudio.org</a>
<p><b>Note:</b> The :hover selector style
links on mouse-over.</p>
p {
color: red;
}
*:not(p) {
color: green;
}
div:not(#container) {
color: blue;
}
<div id="container">
<p> Lorem ipsum dolor sit amet, consectetur </p>
<a her="#"> Lorem ipsum sit amet, consectetur</a>
</div>
<div> Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. </div>
p::first-line { font-weight: bold; font-size: 1.2em;}
p::first-letter { float: left; font-weight: bold;
font-family: cursive;font-size: 2em;
padding-right: 2px;}
<div id="container">
<p> Lorem ipsum dolor sit amet, adipisicing elit,
sed do tempor. Lorem ipsum dolor sit amet,
adipisicing elit, sed do tempor. Lorem ipsum dolor
sit amet, adipisicing elit, sed do tempor. Lorem
ipsum dolor sit amet, adipisicing elit, sed do
tempor. </p>
</div>
:active, :checked, :default, :dir(), :disabled, :empty, :enabled, :first, :first-child, :first-of-type, :fullscreen,
:focus, :hover, :indeterminate, :in-range, :invalid, :lang(), :last-child, :last-of-type, :left, :link,
:not(), :nth-child(), :nth-last-child(), :nth-last-of-type(), :nth-of-type(), :only-child, :only-of-type, :optional,
:out-of-range, :read-only, :read-write, :required, :right, :root, :scope, :target, :valid, :visited
::after, ::before, ::first-letter, ::first-line, ::selection, ::backdrop
li:nth-child(2) {
color: red;
}
<div id="container">
<ul>
<li> List Item
<ul>
<li> Child </li>
<li> Child </li>
<li> Child </li>
</ul>
</li>
<li> List Item </li>
<li> List Item </li>
<li> List Item </li>
</ul>
</div>
li:nth-last-child(2) {
color: red;
}
<div id="container">
<ul>
<li> List Item
<ul>
<li> Child </li>
<li> Child </li>
<li> Child </li>
<li> Child </li>
</ul>
</li>
<li> List Item </li>
<li> List Item </li>
<li> List Item </li>
</ul>
</div>
p:nth-of-type(2) {
background: #ff0000;
}
<div id="container">
<h1>This is a heading</h1>
<p>The first paragraph.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>
</div>
p:nth-last-of-type(2) {
background: #ff0000;
}
<div id="container">
<h1>This is a heading</h1>
<p>The first paragraph.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>
</div>
p:first-child {
background-color: yellow;
}
<div id="container">
<p>This paragraph is the first child of its parent (body).</p>
<h1>Welcome to My Homepage</h1>
<p>This paragraph is not the first child of its parent.</p>
<div>
<p>This paragraph is the first child of its parent (div).</p>
<p>This paragraph is not the first child of its parent.</p>
</div>
<p><b>Note:</b> For :first-child to work in IE8 and earlier,
a DOCTYPE must be declared.</p>
</div>
p:last-child {
background: #ff0000;
}
<div id="container">
<p>The first paragraph.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>
</div>
div p:only-child {
color: red;
}
<div><p> My paragraph here. </p></div>
<div>
<p> Two paragraphs total. </p>
<p> Two paragraphs total. </p>
</div>
li:only-of-type {
background: #ff0000;
}
<ul>
<li>This is a paragraph.</li>
</ul>
<ul>
<li>This is a paragraph.</li>
<li>This is a paragraph.</li>
</ul>
ul:first-of-type > li:nth-child(2) {
color: red;
font-weight: bold;
}
<div>
<p> My paragraph here. </p>
<ul>
<li> List Item 1</li>
<li> List Item 2</li>
</ul>
<ul>
<li> List Item 3</li>
<li> List Item 4</li>
</ul>
</div>
Credit : http://code.tutsplus.com