Attribution:Except where otherwise noted, the contents of this document are Copyright 2012 Marty Stepp, Jessica Miller, and Victoria Kirst. All rights reserved. Any redistribution, reproduction, transmission, or storage of part or all of the contents in any form is prohibited without the author's expressed written permission.
Otherwise noted: Claude Anderson was given permission to modify the slides for CSSE 290 at Rose-Hulman by author Jessica Miller.
The authors' original slides, based on Web Programming Step by Step, can be seen at http://webstepbook.com.
Some of the examples in some days' slides are from David Fisher at Rose-Hulman, who was kind enough to allow me to use them.
My intention is to mark these examples with [DSF].
alt-/
for name completionctrl-shift-f
to format selected code
<
element attribute="
value"
attribute="
value">
content
</
element
>
<a href="page2.html">Next page</a>
<
element attribute="
value"
attribute="
value" />
<hr />
<img src="bunny.jpg" alt="pic from Easter" />
<hr>
, <a>
,
and <img>
tags are detailed on the next slides.
<hr />
Taga horizontal line to visually separate sections of a page (block)
<p>First paragraph</p> <hr /> <p>Second paragraph</p>
<hr
tag should be immediately closed with
/>
<a>
Link, or "anchor", to another page (inline)
<p> Search <a href="http://www.google.com/">Google</a> or our <a href="lecture01-internet.shtml">lecture 1 Slides</a>. </p>
href
attribute to specify the destination URL
p
or
h1
* Most browsers allow us to violate this rule and many other rules, but we should strive to stick to the rules.
<img>
Inserts a graphical image into the page (inline)
<img src="images/gollum.jpg" alt="Gollum from LOTR" />
src
attribute specifies the image URL (relative or absolute)
alt
attribute describing the image
width
and height
(in pixels) of an image<img src="images/gollum.jpg" alt="Gollum" height="80" width="400" />
<a href="http://theonering.net/"> <img src="images/gandalf.jpg" alt="Gandalf from LOTR" title="You shall not pass!" /> </a>
a
element, the image becomes a link
title
attribute is an optional tooltip which can be added to any element
A way of representing any Unicode character within a web page; necessary when you want to include a character with special HTML meaning
character(s) | entity |
---|---|
< > | < > |
é è ñ | é è ñ |
™ © | ™ © |
π δ Δ | π δ Δ |
И | И |
" & | " & |
&
on a web page?
<!--
...
-->
Comments to document your HTML file or "comment out" text
<!-- My web page, by Suzy Student CSSE 290, Spring 2013 --> <p>CSSE courses can be <!-- NOT --> a lot of fun!</p>
-->
Let's get some practice! (exercise is on next slide)
Follow the link on the schedule page to get the starting code (a ZIP file). Extract the Session02 folder and all of its contents to somewhere on your computer.
<dl>
, <dt>
, <dd>
dl
represents a list of definitions of terms (block)
dt
represents each term, and dd
its definition
<dl> <dt>newbie</dt> <dd>one who does not have skills</dd> <dt>own</dt> <dd>to soundly defeat (e.g. I owned that newbie!)</dd> <dt>frag</dt> <dd>a kill in a shooting game</dd> </dl>
<blockquote>
A lengthy quotation (block)
<p>As Lincoln said in his famous Gettysburg Address:</p> <blockquote> <p>Fourscore and seven years ago, our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal.</p> </blockquote>
<q>
A short quotation (inline)
<p>Quoth the Raven, <q>Nevermore.</q></p>
<p>Quoth the Raven, "Nevermore."</p>
<q>
A short quotation (inline)
<p>Quoth the Raven, <q>Nevermore.</q></p>
<p>Quoth the Raven, "Nevermore."</p>
We don't use quotation marks here for two reasons:
"
<q>
allows us to apply CSS styles to all quotations in a page<p> <a href="http://google.com/search?q=claude&ie=utf-8"> Search Google for Claude </a> </p>
<del>
, <ins>
Content that should be considered deleted or added to the document (inline)
<p> <del>Final Exam</del> <ins>First exam</ins> is on <del>May 16</del> <ins>Dec 19</ins>. </p>
<abbr>
An abbreviation, acronym, or slang term (inline)
<p> Safe divers always remember to check their <abbr title="Self-Contained Underwater Breathing Apparatus">SCUBA</abbr> gear. </p>
<code>
A short section of computer code (usually shown in a fixed-width font)
<p> The <code>ul</code> and <code>ol</code> tags make lists. </p>
sup
and
sub
Tags)
Superscripts and subscripts (inline)
<p> x<sup>3i+2</sup> + y<sub>i</sub> - 6 </p>
<pre>
A large section of pre-formatted text (block)
<pre> Steve Jobs speaks loudly reality distortion Apple fans bow down </pre>
code
tags instead of pre
?<meta>
Information about your page (for a browser, search engine, etc.)
<meta charset="utf-8" /> <meta charset="utf-8" http-equiv="refresh" content="5" /> <!-- Thanks, Dax! --> <meta name="description" content="Authors' web site for Building Java Programs." /> <meta name="keywords" content="java, textbook" />
head
section of your HTML pagemeta
tags often have both the name
and content
attributes
meta
tags use the http-equiv
attribute instead of name
meta
tag with charset
attribute indicates language/character encodingsmeta
tag content-type
stops validator "tentatively valid" warnings
<link href="filename" type="MIME type" rel="shortcut icon" />
<link href="yahoo.gif" type="image/gif" rel="shortcut icon" />
link
tag, placed in the head
section, attaches another file to the page
Instructions.html
file, then follow its link.
<div>
and
<span>
<p> <font face="Arial">Welcome to Greasy Joe's.</font> You will <b>never</b>, <i>ever</i>, <u>EVER</u> beat <font size="+4" color="red">OUR</font> prices! </p>
b
, i
, u
, and font
are discouraged in strict HTML
<link>
<head> ... <link href="filename" type="text/css" rel="stylesheet" /> ... </head>
<link href="style.css" type="text/css" rel="stylesheet" />
.css
file (preferred)1. Attribute of an HTML element:
<p style="color:green; font-weight:bolder;">bold green text</p>
1. Attribute of an HTML element:
<p style="color:green; font-weight:bolder;">bold green text</p>
2. In an HTML file's head
section:
<style> li {font-size: 85%;} p {background-color: rgb(90, 0, 129);} </style>
1. Attribute of an HTML element:
<p style="color:green; font-weight:bolder;">bold green text</p>
2. In an HTML file's head
section:
<style> li {font-size: 85%;} p {background-color: rgb(90, 0, 129);} </style>
3. In a separate CSS file. link
tag goes in the head
section of an HTML file.
<link href="Schedulestyle.css" type="text/css" rel="stylesheet" />
selector { property: value; property: value; ... property: value; }
p { font-family: sans-serif; color: red; }
*
selector selects all elements on the page
p { color: red; background-color: yellow; }
This paragraph uses the style above.
property | description |
---|---|
color
|
color of the element's text |
background-color
|
color that will appear behind the element |
p { color: red; } h2 { color: rgb(128, 0, 196); } h4 { color: #FF8800; }
This paragraph uses the first style above.
aqua
,
black
, blue
,
fuchsia
, gray
,
green
, lime
,
maroon
, navy
,
olive
, purple
,
red
, silver
,
teal
, white
(white),
yellow
, 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 CSS properties |
font-family
p { font-family: Georgia; } h2 { font-family: "Courier New"; }
This paragraph uses the first style above.
font-family
p { font-family: Garamond, "Times New Roman", serif; }
This paragraph uses the above style.
font-family
value ensures that every computer/browser will find a valid font to usefont-size
p { font-size: 14pt; }
This paragraph uses the style above.
px
) vs.
point (pt
) vs. m-size (em
)16px
, 16pt
, 1.16em
xx-small
, x-small
, small
, medium
, large
, x-large
, xx-large
, smaller
, larger
90%
, 120%
pt
specifies number of point, where a point is 1/72 of an inch onscreenpx
specifies a number of pixels on the screenem
specifies number of m-widths, where 1 em is equal to the font's current sizefont-weight
,
font-style
p { font-weight: bold; font-style: italic; }
This paragraph uses the style above.
normal
to turn them off (e.g. headings)