basic html tags
basic html tags
What are Internet protocols?
the rules for transferring information between programs
HTTP - hypertext transfer protocol
FTP - file transfer protocol
SMTP – simple mail transfer protocol
1
How the WWW Works
How does a Web Browser (Firefox) fit in this picture?
- your browser connects, using the HTTP protocol, to a web server
- the web server fetches an HTML web page and sends the HTML to your browser
- your browser turns the HTML page into a nice-looking page on your screen
Internet
connection
Internet
Their computer,
Routers
Their web server /mypage.html
(an HTTP server)
Your computer, e.g. Apache
Your web browser Text file containing
e.g. Firefox an HTML web page
2
Hyper Text Markup Language - HTML
Hyper Text Markup Language (HTML) Basics
HTML is a “mark-up language”
You add the mark-up tags to your text document
Now follows a published standard via http://w3c.org/
HTML is a language of mark-up “tags” in angle brackets: <>
each tag has a name and may have one or more quoted attributes
eg. <p class=”thesis” style=”color: red”>
Tags usually come in pairs (with some exceptions)
<html>...</html>, <body>...</body>, <p>...</p>, <hr>, <br>
Web pages are free-form input; line breaks can be used most
anywhere and don't affect the appearance of the document
Yes, your entire page could be a single line of text!
3
HTML – Required Tags
4
HTML – Required Tags
5
HTML – Required Tags
6
HTML – Required Tags
That's all you need for a basic web page!
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>My Title</title>
</head>
<body>
<p>This is my first web page.</p>
</body>
</html>
7
HTML - Basic Tags
Comment Tag
<!-- comments here -->
notice that the comment is typed as an attribute inside the tag
comments may be one or multiple lines long (HTML is free-form)
text within this tag will not be displayed or processed by your browser
comments do not nest! No comments inside comments!
The comment may not contain two (or more) adjacent dashes, e.g. --
8
HTML - Basic Tags
The Anchor Tag – Hyper Linking - making the web a web
<a> … </a>
9
HTML - Basic Tags
<a>…</a> anchor tag continued
10
HTML - Basic Tags
11
HTML - Basic Tags
• <hr> (no closing tag needed)
– Hard/Horizontal Rule – draw a horizontal line
– rule appearance can be changed with styles
• <blockquote> … </blockquote>
– block quotation, indented
• <q> … </q>
– a short, in-line “quotation as part of running text”
• <pre> … </pre>
– preformatted text (e.g. computer code or output)
– fixed-width font (e.g. Courier fixed width)
– preserves spaces and line breaks
12
HTML - Basic Tags
• Font-style tags – for more control, use CSS instead
• <tt> … </tt>
– Teletype Text: fixed-width font (e.g. Courier)
13
HTML - Phrase Tags
Phrase tags – often better done using CSS
14
HTML – Style Element/Attribute
The <style> element and the style= attribute
• The style= attribute can be used on most tags
– defines features for a single HTML element, e.g.
<p style=”text-align: center”>Center me.</p>
15
HTML - Lists
Lists – <ul> Unordered List and <ol> Ordered List
<ul> <ol>
<li>Apple</li> <li>Apple</li>
<li>Pear</li> <li>Pear</li>
<li>Kiwi</li> <li>Kiwi</li>
<li><ul> <li><ul>
<li>Big</li> <li>Big</li>
<li>Small</li> <li>Small</li>
</ul></li> </ul></li>
</ul> </ol>
List attributes
• UNNUMBERED AND NUMBERED LISTS
BEGIN WITH
• <UL> </UL> AND <OL></OL> TAGS
• AND THEN USES <LI>
• TYPE= CIRCLE
• TYPE=SQUARE
• TYPE=DISC
• START=5 TYPE=‘i’
• <ul>…</ul>
– surrounds an unordered list – no numbering
– <li>...</li> items each indented and bulleted
– use styles (style= attribute) to change type of bullet:
– CSS style: list-style-type: string
• string can be: circle, disc, square
• e.g. <ul style=”list-style-type: square”> ... </ul>
18
HTML – Ordered Lists
• <ol> … </ol>
– surrounds an ordered list
– items are indented and numbered (or alphabetized)
– use styles (style=) to change type of numbering:
– CSS style: list-style-type: string
• examples of string: decimal, lower-alpha, upper-roman
• e.g. <ol style=”list-style-type: upper-latin”> ... </ul>
– the start= attribute determines first item's value
• e.g. <ol start=“3”> - begin numbering at 3 (or c, or iii)
• but this is deprecated, with no CSS replacement!
19
HTML – Definition List
• <dl>…</dl>
– definition list containing <dt> and <dd> items
– <dt>...</dt> definition title
– <dd>...</dd> definition description
• Example definition list containing two definitions:
<dl>
<dt>Hacker</dt>
<dd>An expert or enthusiast of any kind.</dd>
<dt>Cracker</dt>
<dd>An intruder into computer systems.</dd>
</dl>
20
HTML - <meta> - Page Attributes
• <meta> (no closing tag needed)
– used only inside <head> section of page
– gives details about page, e.g. author, keywords
– search engines may ignore keywords, since many
pages use fake keywords to boost search results
<head>
<title>Web Design Course Homepage</title>
<meta name="Keywords" content=”Fundamentals, HTML, CSS”>
<meta name="Description" content=”An introductory course
dealing with computer and Internet fundamentals.">
<meta name="GENERATOR" content="Arachnophilia 5.4">
</head>
21
HTML - <meta> - continued
• elements of <meta> include:
– name=string identifies what type of meta content will follow
– content=string details relating to the name
22
HTML – Identify/Group Tags
Identifying and Grouping elements (e.g. for CSS)
• <div>...</div>
– division or section
– groups and identifies one or more block-elements
– usually causes a line break before and after
• <span>...</span>
– groups and identifies in-line elements (e.g. words)
– no visual change by itself (no line break)
– used to apply styles to parts of a text line, e.g.
This <span style=”color: red”>red</span> apple.
23
HTML – Entities (Special Characters)
HTML Entities – for special characters, accents, foreign
– starts with ampersand and ends with semicolon
24
Tag Attributes
• The structure of an HTML tag may contain one or more
attributes like this:
– <tag>
– <tag attribute=“value”>
– <tag attribute=“value” attribute=“value”>
6-25
Align Attribute
<P align="center">
– Centers a paragraph
<P align="right">
– Right-aligns a paragraph
<P align="left">
– Left-aligns a paragraph (the default setting)
Align works the same on header tags
<H1 align="center">
<H2 align="center">
And so on
<p><font size="5" face="arial" color="red">
This paragraph is in Arial, size 5, and in red text color.
</font>
</p>
6-26
Page Properties
Attributes for BODY Tag
– text
• Color for the text in the page
– bgcolor
• Background color for the page
– Foreground
• <body text=color>
– link
• Color for the hypertext links
– vlink
• Color for the visited links
– alink
• Color for the active link
BACKGROUND=“URL”
Specifies the relative or absolute location of an image file that tiles
across the document’s background. 6-27
LEFTMARGIN=“n”
Specifies the width (in pixels) of a margin of white space
along the left edge of the entire document.
TOPMARGIN=“n”
Specifies the size (in pixels) of a margin of white space along
the top edge of the entire document.
SCROLL=“YES, NO”
Indicates whether scrolling is possible within the document
body.
Colors in HTML
• Common names: “red,” “purple,” “gray,” etc
• Hexadecimal triplets
• Red, Green, and Blue are written as:#RRGGBB
• For example:
– White is #FFFFFF, black is #000000, and yellow would
be #FFFF00