Masters student in CS at the Paul G. Allen School
Has been a Head TA for CSE 154 over the last two years
Is pursuing a career in CS education after her studies, and is very excited to be co-teaching CSE 154 this quarter
Is at the Grace Hopper Celebration Conference this week - will introduce
herself on Monday
Is back in Seattle! Find out more on your QuickCheck exercise - the live version is here. (Note: we'll be adding to the HTML during lecture)
Administrivia
Review: HTML5 Semantic Tags
Introduction to CSS (enough to get you started with inspecting pages and adding basic styles - more in section tomorrow)
By the end of this module, you should:
General outline of a document body (template):
<body>
<header>
<!-- Header of the webpage body (e.g. logo, navigation bar) -->
</header>
<main>
<!-- Main section of the webpage body (where most content is) -->
</main>
<footer>
<!-- Footer of the webpage body (e.g. copyright info) -->
</footer>
</body>
<main>
Main content of the document - unlike <header> and <footer> tags, there can only be one main element in the <body>. The content inside should be unique and not contain content that is repeated across pages ( e.g. sidebars, nav link, search bars, etc.)
<header>
Header element - contains header information for page body or section/article, including logos, navigation bar, etc.
<footer>
Footer element - contains footer information for page boy or section/article, including copyright infromation, contact, links, etc.
article
vs. section
Elements<section>
Represents a generic section of a document or application. A section, in this context, is a thematic grouping of content, typically with a heading.
Examples: Section of a chapter, slide element in an HTML-based presentation, etc.
<article>
Represents a self-contained composition in a document, page, application, or site and that is, in principle, independently distributable or reusable, e.g. in syndication.
Examples: A blog or social media post (for pages with multiple posts, there may be multiple
article
s)
Back to the QuickCheck. What HTML elements do you see?
<head> <header> <main> <footer> <article> <section> <nav> <input> <title></title> <ol></ol> <ul></ul> <li></li> <h1></h1> <hr /> <code></code> <b></b> <strong></strong> <button></button>
CSS
A project using different CSS templates to style the same HTML page.
Poll: Which style do you like best?
Consider the following HTML:
<p>
<font face="Arial">Welcome to Paperclips Inc.</font>
You will <b>never</b>, <u>EVER</u> beat
<font size="+4" color="red">OUR</font> prices! <i>(Mr.
Clippy's got nothing on us.)</i>
</p>
Welcome to Paperclips Inc. You will never, EVER beat OUR prices! (Mr. Clippy's got nothing on us.)
Tags such as b, i, u
and font
are discouraged in
strict HTML. Why?
<head>
...
<link href="filename" rel="stylesheet" />
...
</head>
<link href="style.css" rel="stylesheet" />
CSS describes the appearance and layout of information on a web page (as opposed to HTML, which describes the content)
Can be embedded in HTML or placed into separate .css
file (preferred)
selector {
property: value;
property: value;
...
property: value;
}
p {
color: red;
font-family: sans-serif;
}
A CSS file consists of one or more rules
A rule selector specifies HTML element(s) and applies style properties
*
selects all elementsCSS Rules | Description |
---|---|
color ,
background-color
|
Foreground (text) color and background color styles |
font-family ,
font-size ,
font-style ,
font-weight
|
Various font styles |
text-align ,
text-decoration ,
text-indent ,
text-shadow ,
text-transform
|
Various text styles |
line-height ,
word-spacing ,
letter-spacing
|
Line/word/letter spacing styles |
list-style-type |
List item styling (e.g. bullet styles) |
background-image ,
background-repeat ,
background-position ,
background-attachment ,
background-size
|
Various background styles |
p {
color: red;
background-color: yellow;
}
This paragraph uses the style above.
Property | Description |
---|---|
color | color of an element's text |
background-color | background color that will appear behind the element |
Property | Description |
---|---|
font-family | which font will be used |
font-size | how large the letters will be drawn |
font-style | used to enable/disable italic style |
font-weight | used to enable/disable bold style |
Complete list of font properties |
font-family
h4 {
font-family: "Courier New";
}
p {
font-family: Georgia;
}
This paragraph uses the first style above
Enclose multi-world font names in quotes
font-family
p {
font-family: Garamond, "Times New Roman", serif;
}
This paragraph uses the above style
Can specifiy multiple fonts from highest to lowest priority
Generic font names:
If the first font is not found on the user's computer, the next is tried
Generally should specify similar fonts
Placing a generic font name at the end of your
font-family
value ensures that every computer will use a valid font
font-size
p {
font-size: 14pt;
}
This paragraph uses the above style
Vague font sizes: xx-small, x-small, small, medium, large, x-large, smaller, larger,
Percentage font sizes: 90%, 120%
font-style
,
font-weight
p {
font-style: italic;
font-weight: bold;
}
This paragraph uses the above style
Either of the above can be set to normal to turn them off (e.g., headings)
Property | Description |
---|---|
text-align
|
alignment of text within its element |
text-decoration
|
decorations such as underlining |
text-indent
|
indents the first letter of each paragraph |
text-shadow
|
a colored shadow near an existing piece of text (CSS3) |
text-transform
|
controls capitalization of text |
line-height ,
word-spacing ,
letter-spacing
|
gaps between the various portions of the text |
Complete list of text properties |
text-align
blockquote { text-align: justify; }
h2 { text-align: center; }
[TO LUKE SKYWALKER] The alliance... will die. As will your friends. Good, I can feel your anger. I am unarmed. Take your weapon. Strike me down with all of your hatred and your journey towards the dark side will be complete.
Can be left
, right
, center
,
or justify
(which widens all full lines of the element so that they occupy
its entire width)
text-decoration
p { text-decoration: underline; }
This paragraph uses the style above
Can also be overline, line through, blink or none
Effects can be combined:
p { text-decoration: overline underline; }
This paragraph uses the style above
text-shadow
p {
font-weight: bold;
text-shadow: -2px 5px gray;
}
This paragraph uses the style above
shadow
is specified as an X-offset, a Y-offset, or an optional color
text-transform
I just just CAN'T make up my mind!
em {
text-transform: lowercase;
}
span {
text-transform: capitalize;
}
strong {
text-transform: uppercase;
}
I just CAN'T make up my mind!
list-style-type
property
ol { list-style-type: lower-roman; }
Possible values:
none
: No markerdisc
(default), circle, square
decimal
: 1, 2, 3, etc.decimal-leading-zero
: 01, 02, 03, etc.lower-roman
: i, ii, iii, iv, v, etc.upper-roman
: I, II, III, IV, V, etc.lower-alpha
: a, b, c, d, e, etc.upper-alpha
: A, B, C, D, E, etc.lower-greek
: alpha, beta, gamma, etc.hebrew, armenian, georgian,
cjk-ideographic, hiragana, katakana, hiragena-iroha,
katakana-iroha
Property | Description |
---|---|
background-color
|
color to fill background |
background-image
|
image to place in background |
background-position
|
placement of background image within element |
background-repeat
|
how background image should be repeated |
background-attachment
|
whether background image scrolls with page |
background-size
|
how large the background appears behind the element |
background
|
shorthand to set all backgroud properties |
More background properties |
background-image
body {
background-image: url("paw.jpg");
}
This is the first paragraph
This is the second paragraph...
It occupies 2 lines
Background image/color fills the element's content area
background-repeat
body {
background-image: url("paw.jpg");
background-repeat: repeat-y;
}
This is the first paragraph
This is the second paragraph...
It occupies 2 lines
Can be repeat
(default), repeat-x
,
repeat-y
, or no-repeat
background-position
body {
background-image: url("paw.jpg");
background-repeat: no-repeat;
background-position: 370px 20px;
}
This is the first paragraph
This is the second paragraph...
It occupies 2 lines
Value consists of two tokens, each of which can be top
,
left
, right
, bottom
,
center
, a percentage, or a length value in px, pt, etc.
Value can be negative to shift left/up by a given amount