How I Learned to Stop Worrying and Love the Quirks
The Elements of Style
| 1989 | 1994 | 1995 | 1996 | 1997 | 2014 |
|---|---|---|---|---|---|
|
HTML first proposed by Tim Berners-Lee |
CSS first proposed by Håkon Wium Lie |
HTML standardized (HTML2) JavaScript first proposed by Netscape |
CSS standardized (CSS1) |
JavaScript standardized (ECMAScript 1) |
Current version of HTML (HTML5) |
<font /> tags everywhere
<font color="gray" face="monospace">W</font>
to go <b><font color="blue">UP</font></b>
<font color="gray" face="monospace">A</font>
to go <b><font color="blue">LEFT</font></b>
<font color="gray" face="monospace">S</font>
to go <b><font color="blue">DOWN</font></b>
<font color="gray" face="monospace">D</font>
to go <b><font color="blue">RIGHT</font></b>
<span class="key">W</span>
to go <span class="direction">UP</span>
<span class="key">A</span>
to go <span class="direction">LEFT</span>
<span class="key">S</span>
to go <span class="direction">DOWN</span>
<span class="key">D</span>
to go <span class="direction">RIGHT</span>
The Good, the Bad, and the Weird
.key {
color: gray;
font-family: monospace;
}
.direction {
color: blue;
font-weight: bold;
}
Precedence
!importantSource
<span style="color: red;">Hello, world!</span>
<style type="text/css">
span {
color: red;
}
</style>
<link href="style.css" rel="stylesheet" type="text/css"></link>
#about).row, :hover)
a, ::before)
<div id="about">
<a class="row" href="tel:5558675309">Phone: (555) 867-5309</a>
<a class="row" href="mailto:noreply@example.com">Email: noreply@example.com</a>
</div>
#about a.row:hover::before {
/* specificity 1-2-2 */
}
a:hover {
/* specificity 0-1-1 */
}
float
display propertyposition: absolute; and
position: fixed; take elements out of flow entirely
z-index only works with set
position—a new stacking context
z-index orders within the contextfloat and negative margin
The order here is 2 > 1 > 4 > 3 > 5 > 6.
position) if possibleIn Case of Emergency, Break Rules
Do unto others twenty-five percent better than you expect them to do unto you. The twenty-five percent is for error.
Linus Pauling
<div class="quote">
<div class="quote-text"> ... </div>
<div class="quote-author">LINUS PAULING</div>
<div class="quote-mark">“</div>
</div>
<script type="text/javascript">
$('.quote').hover(function() {
$('quote-author').show();
}, function() {
$('quote-author').hide();
});
</script>
<blockquote class="quote">
<p>Do unto others twenty-five percent better than you expect them to do unto you. The twenty-five percent is for error.</p>
<cite>Linus Pauling</cite>
</blockquote>
<style type="text/css">=
.quote::before {
content: '\201c';
font-size: 4em;
}
.quote cite {
height: 0;
opacity: 0;
text-transform: uppercase;
transition: height 400ms, opacity 400ms;
}
.demo-quote:hover cite {
height: 1em;
opacity: 1;
}
</style>