paperlined.org
dev > web > formats > css
document updated 10 years ago, on Jul 13, 2014
Snippets of code that I tend to cut-n-paste a lot.

links aren't underlined unless you :hover

/* --==##  links aren't underlined unless you :hover  ##==-- */
a:link:hover {text-decoration:underline; background-color:#aaf}
a:visited:hover {background-color:#faf}
a {text-decoration:none}
@media print { a {text-decoration:underline} }

grayed-out text

I use this a lot for digressions.
/* --==##  text is grayed-out for digressions  ##==-- */
.digression     {color:#aaa}
span.digression {margin-left:2em}
.digression     a {color:#aaf}
.digression     a:visited {color:#e9e}

make h1/h2/h3 stand out with bars

/* --==##  make h1/h2/h3 stand out with bars  ##==-- */
h1, h2, h3 {padding:0.3em; border-top:2px solid #000; border-bottom:2px solid #000; background-color:#ccc; margin-top:2em}
body>h1:first-child, body>h2:first-child, body>h3:first-child {margin-top:0}

indent everything but headers

/* --==##  indent everything but headers  ##==-- */
body {margin-left:4%}
h1, h2, h3, h4, .lead {margin-left:-3%}

table cells have a nice border

/* --==##  table cells have a nice border  ##==-- */
table {border-collapse:collapse}
td, th {border:1px solid #aaa; padding:0.3em}
th {background-color:#000; color:#fff}
th a {color:#aaf}
th a:visited {color:#faf}

selectively make ul/ol spaced or non-spaced (cascading)

/* --==##  selectively make ul/ol spaced or non-spaced  (cascading) ##==-- */
.spaced .nonspaced li {margin-bottom:0em}
.nonspaced .spaced li {margin-bottom:1em}
.spaced li {margin-bottom:1em}
.nonspaced li {margin-bottom:0em}

selectively make ul/ol spaced (non-cascading)

/* --==##  selectively make ul/ol spaced (non-cascading)  ##==-- */
ul.spaced > li, ol.spaced > li {margin-bottom:1em}
.spaced > li > .spaced {margin-top:1em}

turn things on/off for printing

/* --==##  turn things on/off for printing  ##==-- */
@media print  { .noprint   {display:none} }
@media screen { .printonly {display:none} }

pre/tt have green backgrounds

/* --==##  pre/tt have green backgrounds  ##==-- */
tt, pre {background-color:#afa}
pre {padding:0.3em}

TOC (table of contents) distinctive styling

/* --==##  Table of Contents distinctive styling  ##==-- */
div.toc {margin-left:4em; background-color:#ddd; padding:0.3em; border:1px solid #666; display:inline-block}

add space after the first element within <li>s

/* --==##   add space after the first element within <li>s  ##==-- */
.space_after_first > li > *:first-child {margin-right:2em}