Lecture 4
Lecture 4
</p>
BASIC HTML TAGS
HTML documents begin and
<HTML> end with <html> and </html>
tags
<HEAD>
Comments appear between <!--
<TITLE> test and -->
page</TITLE>
HEAD section enclosed
</HEAD> between <head> and </head>
11
TEXT LAYOUT
<html> for the most part, layout of the text
</p>
can cause a line break using the <br/>
<p>
tag (no closing tag)
This is another paragraph with a
GAP between
can specify a new paragraph (starts on
some of the words.
a new line, preceded by a blank line)
</p>
using <p>…</p>
<p>
This paragraph is<br/>
can force a space character using the
indented on the first line<br/> symbol for a non-breaking space:
but not on subsequent lines.
</p>
</body>
</html>
SEPARATING BLOCKS OF TEXT
<html> can specify headings for
<!-- comment Internet Programing 2010--
paragraphs or blocks of text
>
<head> <h1>…</h1> tags produce a large,
<title>Blocks of Text</title>
</head> bold heading
<h2>…</h2> tags produce a
<body> slightly smaller heading
<h1>Major heading 1</h1> ...
<p>
Here is some text.
<h6>…</h6> tags produce a tiny
</p> heading
<h2>Subheading</h2>
<p> can insert a horizontal rule to
Here is some subtext. divide sections
</p>
<hr/> <hr/> draws line across window
<h1>Major heading 2</h1>
<p>
<hr width="50%" /> sets width
Here is some more text. <hr size=10 /> sets thickness
SEPARATING BLOCKS OF TEXT
HTML allows you to omit the (start or) end
tags when it is obvious where the element
(begins or) ends.
For instance, consider
<p>Some text</p>
item</li> </ul>
We can omit the closing </p> tags and </li>
ALIGNING TEXT
<html>
<!-- comment Internet Programing 2010 -->
<!-- Demo web page -->
can specify
<head>
<title>Text Alignment</title> how elements
</head> should be
aligned (default
<body>
<h1 style="text-align:center">Centered is left-justified)
Heading</h1> utilize STYLE
<p>
Here is some left-justified text attribute of
(which is the default in HTML). tag
</p>
to justify more
<p style="text-align:center"> than one
Here is some centered text.
</p>
element as a
group, use DIV
<div style="text-align:right"> tags
<h2>Right-justified Heading</h2>
<p>Here is some right-justified text.</p>
elements
</div> enclosed in
</body>
DIV are
</html> formatted
similarly
TEXT STYLES can specify styles for fonts
<html> <b>… </b> specify bold
<!-- comment Internet Programing 2010 -->
<i>… </i> specify italics
<!-- Demo web page -->
<tt>… </tt> specify typewriter-
<head> like (fixed-width) font
<title>Text Styles</title>
</head>
<big>… </big> increase the size of
the font
<body> <small>… </small> decrease
<p> the size of the font
Text can be emphasized using
<b>bold</b>, <i>italics</i>, or even
<sub>… </sub> specify a subscript
<big>resizing</big>. <br/> <sup>… </sup> a superscript
The typewriter font is good for <p style="color:red">…</p> for
displaying code:
paragraphs
<tt>sum = sum + i;</tt> <br />
And remember: <span style="color:red"> <span style="color:blue">
<small> 2<sup>10</sup></small> = …</span> for inline text
1024</span>
</p> Note: if elements are nested, the
</body> order of opening/closing is
important!
</html>
MORE TEXT GROUPING
<html>
<!-- comment Internet Programming 2010 --> <pre>…</pre> specify text
<head> that is to be displayed
<title>More Text Grouping</title>
</head>
as is (line breaks and
spacing are preserved)
<body>
<p>
useful for code or whenever you
<tt><pre> want text to fit a specific
for (i = 0; i < 10; i++) { layout
sum = sum + i;
}
</pre></tt> <blockquote>…</
</p>
blockquote> specify text
<p>
Eagleson's Law states that: that is to be indented on
<blockquote> both margins
Any code of your own that you haven't
looked at for six or more months useful for quotations or for
might as well have been written by indenting text in subsections
someone else.
</blockquote>
</p>
</body>
</html>
LISTS
<html>
<!-- comment Internet Programing 2010 there are 3 different
-->
<head>
types of list elements
<title>Simple Lists</title> <ol>…</ol> specifies an
</head>
ordered list (using
<body> numbers or letters to label
<p> each list item)
<ol>
<li> identifies each list item
<li>First item.
<li>Second item.
can set type of ordering,
<li>Third item. start index
</ol>
</p>
<ul>…</ul> specifies
unordered list (using a
<p> bullet for each)
<dl>
<dt>HTML
<li> identifies each list item
<dd>HyperText Markup Language <dl>…</dl> specifies a
<dt>HTTP
<dd>HyperText Transfer Protocol
definition list
</dl>
<dt> identifies each term
</p>
<dd> identifies its definition
</body>
</html>
HYPERLINKS the most important
HTML element is the
<html>
<!-- comment Internet Programing 2010 -- hyperlink, or ANCHOR
>
<a href="URL">…
<head>
<title>Hyperlinks</title>
</a>
</head> where URL is the Web
<body> address of the page to be
<p> displayed when the user
<a href="http://www.creighton.edu">
Creighton University</a>
clicks on the link
<br> if the page is accessed
<a href="page07.html" target="_blank"> over the Web, must start
Open page07 in a new window</a>
</p> with http://
</body> if not there, the browser
</html>
will assume it is the name
of a local file
<a href="URL"
target="_blank">…</a>
causes the page to be
again, if file is to be accessed over the Web, must start with http:// (if not, will assume local
file)
<html>
<head>
<title>Images</title>
</head>
<body>
<div style="text-align:center">
<img
src="http://www.creighton.edu/~davereed/Images/reed.gif"
alt="Dave Reed" />
<p>Dave Reed</p>
</div>
</body>
</html>
TABLES
tables are common tools for arranging complex layout on a Web page
a table divides contents into rows and columns
by default, column entries are left-justified, so provide for alignment
<html>
<!-- comment Internet Programing 2010 --
>
<table rules=“type”>
type is either “all”, “rows”, “cols”, or “none”
FRAMES
frames provide the ability to split the screen into
independent pages
must define a FRAMESET that specifies the layout of the
pages
actual pages to be displayed must be in separate files
<frameset cols="*,*">
<frame src="page01.html"> or, horizontally
<frame src="page02.html"> <frameset rows="30%,*,*">
</frameset>