Administrivia
More HTML
Discuss Accessible Design
Start CSS
Zoom chat expectations: used for asking content-relevant questions.
Zoom notifications: What zoom notifications?
Log into GitLab to ensure your account is set up.
WPL available for getting help from TAs.
Office Hours available for getting help from Instructors (generally right after lecture).
Sections
CP1 out now - Have fun; this is your opportunity to explore and get feedback for HW1 (released next week)
Also, sign up for Mentor Circles by tomorrow! (but the sooner the better)
Due: Wed, Apr 8th, 11:00 pm
Lock: Fri, Apr 10th, 11:00 pm
The Good
The Bad
The Ugly
CSE 154 A Sp 20: Web Programming just sent you a message in Canvas
From Wikipedia
Content
Words and images
Structure
HTML
Style
CSS
Behavior
JavaScript & Server programs
Describes the content and structure of information on a web page
There are a ton of HTML tags, but the most important thing is to use ones that are semantically appropriate, and meet current web standards.
MDN is really the only resource you should use outside of this class for looking up specific tags.
<!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
An HTML page is saved into a file ending with extension .html
The DOCTYPE
tag tells the browser to interpret our page's code as HTML5, the
lastest/greatest version of the language
Image source: Hudson Gilmore (CSE154 TA!)
Always start with a sketch/wireframe before jumping into code!
A great resource on getting started with wireframes can be found here.
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>
HTML
For different types of pages, you may have more elements (e.g. nav
,
aside
), but these are the ones you should
follow as a guide for most of your webpages.
<!DOCTYPE html>
<html>
<head>
<title>Koala Fan Page</title>
</head>
<body>
<header>
<h1>A Koala-tee Webpage</h1>
</header>
<main>
<aside>
<!-- Left sidebar -->
</aside>
<section>
<!-- Koala facts (header and paragraphs)-->
<article>
<!-- Koala art gallery -->
</article>
</section>
</main>
<footer>
<!-- Image citations -->
</footer>
</body>
</html>
<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 body or section/article, including copyright information, contact, links, etc. Also often used with block quotes to cite sources (see CP1 about.html for an example!).
article
vs section
We get this question a LOT
Others ask this too
Here are two resources to help you:
Articles are complete, standalone content. Sections are pieces of a greater whole.
And remember: div
div has no semantic meaning,
should only be added for selecting content in CSS/JS, and should be your "last resort"
Some tags can contain additional information called attributes
<element
attribute="value"
attribute="value">
content </element>
<a href="my-other-page.html">Next page</a>
Some tags don't contain content and can be opened and closed in one tag (self-closing or "void")
<element attribute="value" attribute="value">
<br>, <hr>
<img src="bunny.jpg" alt="pic from Easter">
<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>
<img>
Inserts a graphical image into the page (inline)
<img src="img/koala-with-leaf.png" alt="A Koala with a leaf" 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.
The value of the alt
attribute is also what you see if the image is not
successfully loaded.
<img src="img/koala-with-leaf-broken.png" alt="A Koala with a leaf" title="Logo">
HTML
output
<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.
Relative: paths are relative to the document linking to the path.
<a href="my-other-page.html">Check out my other page!</a>
<img src="img/koala-with-leaf.png" alt="A Koala with a leaf" title="Logo">
Absolute: paths refer to a specific location of a file, including the domain and protocol.
How to cite images that aren't yours?
<figure>
<!--
Image source: Wikipedia, Made by User:Golbez
[CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/)]
-->
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Australia_states_blank.png/257px-Australia_states_blank.png"
alt="Koala-land map">
<figcaption>Koalas live in Australia</figcaption>
</figure>
HTML
See slides below for how to get the citation image for this Wikimedia image.
In your CP's, you must cite all resources that were not original (and you should give your own images credits) either on the page (as in about.html or in a footer) and/or in the page source code.
More examples:
A list can contain other lists:
<ul>
<li>Koalas are marsupials</li>
<li>Koalas like to eat Eucalyptus plants
<ul>
<li>
They take up to 100 hours to digest their food!
</li>
</ul>
</li>
<li>
The latin name for koalas is
<em>Phascolarctos cinereus</em>
("ash-colored pouch bear")
</li>
</ul>
HTML
a way of representing any Unicode character within a web page
character(s) | entity |
---|---|
< > | < > |
é è ñ | é è ñ |
™ © | ™ © |
π δ Δ | π δ Δ |
И | И |
" & | " & |
&
on a web page?What if I wanted to put THIS into a rendered web page?
<p> <a href="http://google.com/search?q=grumpy+cat&ie=utf-8"> Search Google for grump cat </a> </p>
output
To display the link text in a web page, its special characters must be encoded like this in the HTML:
<p>
<a href="http://google.com/search?q=grumpy+cat&ie=utf-8">
Search Google for grumpy cat
</a>
</p>
HTML
View the above output in this example
Practice: How can you fix this page to show <pre> using HTML entities?
You don't need to memorize all of the HTML tags, but should be able to use the right tag for the right purpose (semantics).
Refer to this slide deck for a list of the common tags you should know, and MDN's element reference for a much more comprehensive and detailed list (includes browser compatibility for each!)
Block elements contain an entire large region of content
Inline elements affect a small amount of content
<em>text</em>
<em>text</em>
<em>text</em>
<p>text</p>
<p>text</p>
<p>text</p>
HTML
text text text
text
text
text
output
Block vs. inline:
<body>
, <form>
<p>
tags can contain only inline elements and plain
text
<div>, <li>
Some elements are only allowed to contain certain other elements:
<ul>
is only allowed to contain <li>
(but
<li>
can contain <ul>
for nested lists!)
Some elements are only allowed once per document:
<html>
,
<body>
,
<head>
,
<main>
Tags can "nest" inside of other tags
<body>
<p>
This is a <em>really, <strong>REALLY</strong></em> awesome paragraph.
And here's a neat list:
</p>
<ol>
<li>with one list item</li>
<li>with another list item</li>
</ol>
</body>
HTML
This is a really, REALLY awesome paragraph. And here's a neat list...
output
<p>
HTML is <em>really,
<strong>REALLY</em> lots of</strong> fun!
</p>
Incorrectly nested HTML
Tags must be correctly nested
How would we get the above effect in a valid way?
<p>
HTML is <em>really,
<strong>REALLY lots of</strong></em> fun!
</p>
Correctly nested HTML
NOTE: To receive full credit on your creative projects and homework assignments you MUST validate all of your files and pass with no errors.
Moreover, it is important to write proper HTML code and follow proper syntax
Why use valid HTML5 and web standards?
This is another great resource to learn more about why/how to make websites accessible!
Who uses the web?
What are the different ways people visit and interact with websites?
Why is it important to think about users when developing websites?
Everyone has different abilities
Nearly 1 in 5 people have a disability in the U.S. (from the U.S. Census)
from W3C Web Accessibility Initiative (WAI)
Disabilities can be temporary
Disabilities can be situational
Disability affects all of us
Designs that account for all abilities are called accessible designs
Enable your phone's screen reader
Input works differently now. For example, tap now reads the screen and double-tap selects. Use two or three fingers to scroll by page. Play with it for a minute.
Try closing your eyes and reading a webpage or a social networking site. Try writing an email.
Medical view
Legal view
Sociocultural view
From the A11y Project
Tools
Resources
<article>
,
<strong>
<b>
<html lang="en">
Note: These design principles help in other ways as well
More about HTML and accessibility here.
<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>
HTML
Welcome to Greasy Joe's. You will never, ever, EVER beat OUR prices!
output
Tags such as b, i, u
and font
are discouraged in strict HTML
Why is this bad?
<head>
...
<link href="filename" rel="stylesheet">
...
</head>
HTML (template)
<link href="style.css" rel="stylesheet">
HTML (example)
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;
}
CSS (template)
p {
color: red;
font-family: sans-serif;
}
CSS (example)
A CSS file consists of one or more rules
A rule selector specifies HTML element(s) and applies style properties
*
selects all elements