<!DOCTYPE html>
<html>
<head>
information about the page
</head>
<body>
page contents
</body>
</html>
HTML
The <head>
tag describes the page and the <body>
tag
contains the page's content
The DOCTYPE
tag tells the browser to interpret our page's code as
HTML5, the lastest/greatest version of the language
You can find a starter template here!
head
TagsTag | Description |
---|---|
<title> |
Page title (shown in browser tab) |
<meta> |
Meta information tag |
<favicon> |
Icon placed in the browser tab and bookmarks |
<title>
<title>
Chapter 2: HTML Basics
</title>
HTML
Placed within the <head>
of the page
Displayed in the web browser's title bar/tab and when bookmarking the page, otherwise not visible to the user as page content
<meta>
information about your page (for a browser, search engine, etc.)
<meta charset="utf-8" />
<meta name="description"
content="Course website for CSE 154" />
<meta name="keywords" content="web programming, CSE154" />
HTML
Placed in the head
section of your HTML page
meta
tags often have both the name
and content
attributes
meta
tag with charset
attribute indicates language/character encodings (usually utf-8)<link href="filename" type="MIME type" rel="shortcut icon" />
HTML (template)
<link href="yahoo.gif" type="image/gif" rel="shortcut icon" />
HTML (example)
The link
tag, placed in the head
section, attaches another file to the page
Note for IE6: Doesn't work; must put a file favicon.ico
in the root
of the web server (info)
body
Tags (1/2)Tag | Description |
---|---|
<p> |
Paragraph tag |
<h1> ... <h6> |
Heading tags |
<em>, <strong> |
Emphasis (italic) and strong (bold) tags |
<abbr> |
Abbreviation tag |
<hr /> |
Horizontal rule tag |
<br /> |
Line break tag |
<a> |
Anchor tag (page links) |
<img /> |
Image tag |
body
Tags (2/2)Tag | Description |
---|---|
<ul> , <ol> |
Unordered and ordered list tags |
<li> |
List item tag (used as children of <ul> or <ol> list tags) |
<dl> , <dt> , <dd>
| Definition list tags |
<blockquote> ,
<q> |
Block and inline quotation tags |
<code> |
Computer code tag |
<pre> |
Preformatting tag |
<p>
paragraphs of text (block)
<p>
You're not your job.
You're not how much money you make in the bank.
You're not the car you drive.
You're not the content of your wallet.
You're not your khakis.
You're not the all-singing, all-dancing crap of the world.
</p>
HTML
You're not your job. You're not how much money you make in the bank. You're not the car you drive. You're not the content of your wallet. You're not your khakis. You're not the all-singing, all-dancing crap of the world.
output
<h1>
,
<h2>
, ...,
<h6>
headings to separate major areas of the page (block)
<h1>University of Whoville</h1>
<h2>Department of Computer Science</h2>
<h3>Sponsored by Micro$oft</h3>
HTML
output
<em>
, <strong>
em
: emphasized text (usually rendered in italic)
strong
: strongly emphasized text (usually rendered in bold)
<p>
HTML is <em>really</em>, <strong>REALLY</strong> fun!
</p>
HTML
As usual, the tags must be properly nested for a valid page
These tags should have semantic purpose, not just to style text with italicized/bold format (we'll learn how to accomplish that in CSS!)
<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>
HTML
Safe divers always remember to check their SCUBA gear.
output
<hr />
a horizontal line to visually separate sections of a page (block)
<p>First paragraph</p>
<hr />
<p>Second paragraph</p>
<hr>
<p>Third paragraph</p>
HTML
First paragraph
Second paragraph
Third paragraph
output
This is the first example we've seen of a void (self-closing
) tag:
more on HTML Element types
<br />
forces a line break in the middle of a block element (inline)
<p>
The woods are lovely, dark and deep, <br />
But I have promises to keep, <br />And miles
to go before I sleep, <br />And miles to go before
I sleep.
</p>
HTML
The woods are lovely, dark and deep,
But I have promises to keep,
And miles
to go before I sleep,
And miles to go before
output
Warning: Don't over-use br
(guideline: >= 2 in a row is bad, better to not use any)
br
tags should not be used to separate paragraphs or used multiple times in a row to create spacing
<a>
links, or "anchors", to other pages (inline)
<p>
Search for it on <a href="http://www.google.com/">Google</a>!
</p>
HTML
Search for it on Google!
output
Uses the href
(Hypertext REFerence) attribute to specify the destination URL
Anchors are inline elements; must be placed in a block element such as
<p>
or <h1>
Use the target="_blank"
attribute to make it open in a new tab!
<img>
Inserts a graphical image into the page (inline)
<img src="img/cse154logo.png" alt="CSE154 Course Logo" title="Logo"/>
HTML
output
The src
attribute specifies the image URL
HTML5 also requires an alt
attribute describing the image, which
improves
accessibility for users who can't otherwise see it
<a href="https://courses.cs.washington.edu/courses/cse154/20sp/">
<img src="img/cse154logo.png" alt="CSE154 Course Logo" title="Logo"/>
</a>
HTML
If placed in an <a>
anchor tag, the image becomes a link
The title
attribute is an optional tooltip (on ANY element, hover over this one!)
BUT the title
attribute doesn't always work well for mobile and
accessibility, so its usage and future are debated
Relative: paths change depending on the page of the link.
"filename.jpg"
"img/filename.jpg"
Absolute: paths refer to a specific location of a file, including the domain.
https://validator.w3.org/
<ul>
,
<li>
ul
represents a bulleted list of items (block)
li
represents a single item within the list (block)
<ul>
<li>No shoes</li>
<li>No shirt</li>
<li>No problem</li>
</ul>
HTML
output
<ol>
ol
represents a numbered list of items (block)
<p>Steps to start a webpage:</p>
<ol>
<li>Choose a purpose</li>
<li>Sketch a wireframe</li>
<li>Markup content with HTML tags</li>
<li>Add style with CSS!</li>
</ol>
HTML
Steps to start a webpage:
output
We can make lists with letters or Roman numerals using CSS (later)
A list can contain other lists:
<ul>
<li>Drinks:
<ul>
<li>Coffee</li>
<li>Tea</li>
</ul>
</li>
<li>Bakery:
<ul>
<li>Poptarts</li>
<li>Bagels</li>
</ul>
</li>
</ul>
HTML
output
<dl>
,
<dt>
,
<dd>
dl
represents a list of definitions of terms (block)
dt
represents each term, and dd
its definition
<dl>
<dt>HTML</dt>
<dd>
Markup language for content
</dd>
<dt>CSS</dt>
<dd>
Language for styling pages
</dd>
<dt>JavaScript</dt>
<dd>
Language for adding interactivity to
websites
</dd>
</dl>
HTML
output
<blockquote>
a 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>
HTML
As Lincoln said in his famous Gettysburg Address:
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.
output
<q>
a short quotation (inline)
<p>Quoth the Raven, <q>Nevermore.</q></p>
HTML
Why not just write the following?
<p>Quoth the Raven, "Nevermore."</p>
We don't use " marks for two reasons:
"
<q>
allows us to apply CSS styles to quotations (seen later)<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>
HTML
The ul
and ol
tags make lists.
output
<pre>
a large section of pre-formatted text (block)
<pre>
Steve Jobs spoke loudly
reality distortion
Apple fans bow down
</pre>
HTML
Steve Jobs speaks loudly reality distortion Apple fans bow down
output
Displayed with exactly the whitespace / line breaks given in the text
Shown in a fixed-width font by default
How would it look if we had instead enclosed it in code
tags?