These notes generally follow the
intro and
header tutorials.
There's also just a bit from
text
fundamentals.
- A Web Page Is
- A text document.
- Contains instructions for formatting.
- Where to web pages come from?
- Our web pages will come from a text editor. We will
create the tags by hand.
- Other places to get HTML:
- Editors and content generation systems which output HTML.
- Export from programs such as word processors.
- Web sites for user content.
- Why do it by hand?
- More control.
- More understanding.
- Can fix the fancy tools when they break, or go around them to
get what you need to.
- Tags
- Undecorated text is displayed in the browser.
- Tags structure the document.
- Opening and closing tags:
<tagname>Content of the tag.</tagname>
- Open and close tags must balance, and may be nested.
Think parentheses.
- The tags and contents are called an element.
- Attributes.
- Attributes are key-value pairs added to the (opening) tag to modify its
behaviour.
- The value can be enclosed in single or double quotes.
- Quotes may sometimes be omitted, but it's asking for trouble.
- <tagname attrname="value">Content displayed accordinging</tagname>
- Block Elements. Control the arrangement of large blocks, such as
paragraphs.
- Paragrpah: <p>
- The paragraph tag has many attributes, for instance, to align the
text:
<p align="center">, and left and right.
- Modern web pages should use CSS instead of these attributes.
- Headings: <h1> through <h6>
- Lists creation <ol>, <ul>, <li>. (More on lists
below.)
- Inline Elements. These control what text looks like, but does not
change the structure of the document.
- The first approach is to specify intent. The browser would decide how
to actually display these.
- <em> Emphasize.
- <strong> Really emphasize!.
- <cite> The Title of Some Work.
- <samp> Sample program output.
- But designers don't like giving up that much control. So
from the
early days there are also specific formatting tags:
- <b> Bold.
- <i> Italic.
- <u> Underline.
- <big> Larger text.
- <small> Smaller text.
- <strike>
Strikeout.
- Modern pages should use CSS to control appearance, rather than the
tags mentioned here.
- Correct page structure:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
Document contents.
</body>
</html>
- The <!DOCTYPE>, suprisingly, declares what type of document
this is.
- The <html>, <head> and <body> tags structure the
document.
- The head contains information about the document; the document itself
is in the body.
- The <meta> tag can provide various information about a
document. Here, it describes how the characters are encoded.
- The <!DOCTYPE> and <meta> tags are two of a very
few that have no closing tag.
- Entities.
- Purposes
- To represent characters which would otherwise be markup.
- To represent characters which are not on the keyboard.
- Format
- Start with ampersand, end with semicolon.
- Numeric, <
- Symbolic, <
- Some entities:
< ⇒ <
> ⇒ >
& ⇒ &
∑ ⇒ ∑
÷ ⇒ ÷
⊆ ⇒ ⊆
¢ ⇒ ¢
£ ⇒ £
© ⇒ ©
λ ⇒ λ
É ⇒ É
Ü ⇒ Ü
ã ⇒ ã
-
Here
is a list.
- Some Uses
- He paid €15 in München.
He paid €15 in München.
- A ⊆ { x | x ≥ 0 ∧ x < 2πr }
A ⊆ { x | x ≥ 0 ∧ x ≤ 2πr }
- HTML comment: <!-- Not displayed -->
- Practical Stuff
- Create a file with a text editor.
- View it locally.
- Copy to the server. View with the web browser.
- Copy changed versions across, press the reload button.
- Browsers may behave differently, though any modern
browser should show a correct page the same way.
- Browsers may be forgiving of errors.
- You may have errors without knowing it.
- You have have odd behavior because of an error.
- Browsers may treat the same error very differently.
- Most browsers have developer tools which you might
want to explore.
- The title tag.
- This gives the title of the document.
- Generally displayed in the browser stripe.
- May be repeated in an H tag, but they are separate things.
- The meta keyword has several forms.
- <meta name="author" content="Your Name Here">
- <meta name="description" content="What this page is about">
- The similar keywords tag was intended for search engines, but they
ignore it now because of abuse.
- The Mozilla tutorial
discusses some newer types created by certain web sites.
- We've already seen meta charset
- Tells the browser how to interpret the bytes in your page as
characters.
- The reasons why there is actually more than one choice are largely
historic.
- Originally, computers pretty much only understood English.
(Or may just American.)
- Various means were proposed to represent other characters; none
was universally adopted.
- These conflicted, and browsers had to guess right or the page
could look horrible.
- HTML finally standardized on the meta charset tag.
- The utf-8 encoding is a good compromize that can represent
any language, but usually doesn't break under old software that
hasn't heard of the rest of the world.
- We will be happy with utf-8 in this class, but feel free to
experiment with the document type if you like.
- Can declare what language the page is written in use HTML tag:
- <html lang="en-US"> (or other).
- Helps with indexing and screen readers.
- The header may contain style, link and/or script tags,
relevent to style sheets and Javascript, which we will discuss later.
- Lists.
- <ul>: Unordered (bullet) list
- <ol>: Order (numbered) list.
- Each item in a list (either type) is a list item.
- Lists may be nested. Default ordered list symbol may change.