Introduction to Web Design for Literary Theorists

Second Workshop:
Overview of CSS

Patrick Mooney
Co-Lead TA, 2013-2015
Department of English
UC Santa Barbara

Objectives for this workshop series

Objectives for today's workshop

Details, details …

What you won't learn in these workshops

Which Is to Say …

Reminders from last time

Reminders from last time

Tags you'll see, but shouldn't use

Presentational Tag Purpose
<b></b>bold text
<big></big>,<small></small> to change text size
<blink></blink> primarily used to ensure that people despise you
<center></center> for centering text
<font></font> for font size and face
<i></i> italic text
<sub></sub>,<sup></sup> subscript, superscript
<u></u>underlined text

Takeaway: There are far better ways to accomplish these things.

A minimally acceptable XHTML document

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhmlt">

<head>
<title>Some books I've read</title>
</head>

<body>

<p>I read many books on my bus trip last summer. Of all of them, the <em>most</em> disappointing was <cite>1Q84</cite>.</p>

</body>
</html>

Some comments on that minimal XHTML document

How CSS works

An example: what <h1> looks like

h1 {font-family: Arial;
    font-size: 36pt;
    text-align: center;}

Reminder: Some attributes are for any tag

More examples

p,td,li {font-family: "Times New Roman";
         font-size: 12pt;
         margin-bottom: 0;}

p.first-paragraph {margin-top: 0;}

p#abstract {font-style: italic;}

More examples

p#abstract {color: red;}
#abstract {font-style: italic;}

More examples

.abstract {font-style: italic;}

More complex selectors

li ol li {margin-top: 0;}

More complex selectors

#nav li ul li a {text-decoration: none;}

More complex selectors

#nav > li {list-style-type: none;}

Tags that do nothing (visible, on their own)

So, where does CSS styling go?

Best practice: in an external style sheet

So, what can you do with declarations?

Example: changing the document background

body {background: white;}
body {background: rgb(255,255,255);}
body {background: #ffffff;}

Example: Changing the background on other things

p.info-box {background: url("paper.png") repeat;}

MLA-compliant text (more or less)

p {font-family: Times New Roman, Times, serif;
   font-size: 12pt;
   text-indent: 0.5in;
   width: 6.5in;
   text-align: left;
   margin: 1in;
   line-height: 200%;}

A few words about fonts

p {font-family: Times New Roman, Times, serif;}

Can't you serve the fonts you want directly from your web site?

Some useful text properties

Property Useful values
font-size 12pt; 120%; 3em
font-family "Arial Black", Arial, sans-serif
font-style normal; italic; oblique; inherit
font-weight normal; bold; 400; bolder; lighter
text-align left; right; center; justify
color black; #000000; rgb(0,0,0)
text-decoration none; overline; blink; underline; line-through
white-space normal; pre; nowrap
text-indent 0.5in; 2ex; 20px; 4pt; 2.5cm; 3pc

The HTML box model

Say you have an HTML file containing two paragraphs:

<body>
  <p>Whatever normcore selvage Schlitz, locavore PBR&B viral. Butcher pork belly slow-carb, 8-bit kitsch PBR food truck ethical kale chips fap. Etsy lo-fi swag mixtape pop-up. Williamsburg keytar meggings.</p>
  <p>Letterpress fixie DIY cred, fap umami ethical McSweeney's small batch cardigan Banksy viral Blue Bottle Intelligentsia disrupt. Deep v ethical literally salvia brunch banjo fanny pack.</p>
</body>

an illustration of the HTML box model

Padding, border, margin

an illustration of the HTML box model

p {background: aqua;
   padding: 0.5in;
   border: 2px purple dashed;
   margin: 1in;}

Useful layout properties

Property Useful settings
clear left, right, both
display inline, block, list-item, table, none
width 800px; 80%; 6.5in; 60em
vertical-align top; baseline; middle; bottom; sub; super
position static; relative; absolute; fixed
top, right, bottom, left 12px; .25in; 3em; 20%
float left, right, none

There are also some shorthand properties

p {font: italic small-caps bold 12pt/24pt "Times New Roman", Times, serif;}
p {font: bold 12pt Times New Roman;}

So that's a lot of detail …

CSS is odd and can be kind of terrible

There are a lot of interacting behaviors no matter what you do, and no matter what you do someone’s going to find the results baffling in some way or other.

— Eric Meyer, Un-fixing Fixed Elements with CSS Transforms

So what's good design, then?

How do you learn decent design?

Some general principles

A few examples of good design

A suggestion …