0% found this document useful (0 votes)
46 views

Hypertext & HTML: Static

Hypertext Markup Language (HTML) is used to specify the content and structure of web pages. HTML uses tags enclosed in angle brackets to identify different elements like headings, paragraphs, lists, and more. The basic structure of an HTML document includes a HEAD section for metadata and a BODY section for visible content. Within the body, tags are used to specify headings, paragraphs, lists, emphasis, alignment, and other styling. This allows HTML documents to contain text, images, and links to provide interactive and multimedia web pages.

Uploaded by

Krishna Likki
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Hypertext & HTML: Static

Hypertext Markup Language (HTML) is used to specify the content and structure of web pages. HTML uses tags enclosed in angle brackets to identify different elements like headings, paragraphs, lists, and more. The basic structure of an HTML document includes a HEAD section for metadata and a BODY section for visible content. Within the body, tags are used to specify headings, paragraphs, lists, emphasis, alignment, and other styling. This allows HTML documents to contain text, images, and links to provide interactive and multimedia web pages.

Uploaded by

Krishna Likki
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 31

Hypertext & HTML

HyperText Markup Language (HTML) is the language for specifying the


static content of Web pages
 hypertext refers to the fact that Web pages are more than just text
can contain multimedia, provide links for jumping within & without
 markup refers to the fact that it works by augmenting text with special symbols
(tags) that identify structure and content type

Web development tools


many high-level tools exist for creating Web pages
e.g., Microsoft FrontPage, Netscape Composer, Adobe PageMill,
Macromedia DreamWeaver, HotDog, …
also, many applications have "save to HTML" options (e.g., Word)

for most users who want to develop basic, static Web pages, these are fine

HTML document is a collection of elements (text/media with context) 1


Tags vs. elements
HTML specifies a set of tags that identify structure and content type
 tags are enclosed in < >

<img src="image.gif" /> specifies an image

 most tags come in pairs, marking a beginning and ending

<title> and </title> enclose the title of a page

an HTML element is an object enclosed by a pair of tags


<title>My Home Page</title> is a TITLE element

<b>This text appears bold.</b> is a BOLD element

<p>Part of this text is <b>bold</b>.</p>


is a PARAGRAPH element that contains a BOLD element

2
Structural elements
an HTML document has two main structural elements
 HEAD contains setup information for the browser & the Web page
e.g., the title for the browser window, style definitions, JavaScript code, …
 BODY contains the actual content to be displayed in the Web page

<html>
<!-- Dave Reed page01.html 1/16/04 --> HTML documents begin and end with <html>
<!-- Demo web page --> and </html> tags
<head>
Comments appear between <!-- and -->
<title>Title for Page</title>
</head>
HEAD section enclosed between <head>
<body> and </head>
Text that appears in the page
</body>
BODY section enclosed between <body>
</html> and </body>

view page in browser

3
Text layout
<html>
for the most part, layout of the text
<head>
<title>Text Layout</title>
must be left to the browser
</head>  every sequence of whitespace is
interpreted as a single space
<body>  browser automatically wraps the text to
<p>
This is a paragraph of text<br/>
fit the window size
made up of two lines.
</p>

<p> can override some text layout


This is another paragraph with a
&nbsp; GAP &nbsp; between
some of the words.  can cause a line break using the
</p> <br/> or <br> tag (no closing tag)
<p>
 can specify a new paragraph (starts on
&nbsp;&nbsp; This paragraph is<br/> a new line, preceded by a blank line)
indented on the first line<br/> using <p>…</p>
but not on subsequent lines.  can force a space character using the
</p>
</body>
symbol for a non-breaking space:
&nbsp;
</html>

view page in browser 4


Separating blocks of text
<html>
<!-- Dave Reed page03.html 1/16/04 --> can specify headings for
<!-- Demo web page --> 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 slightly
<body> smaller heading
<h1>Major heading 1</h1>
<p> ...
Here is some text.  <h6>…</h6> tags produce a tiny
</p> heading
<h2>Subheading</h2>
<p>
Here is some subtext. can insert a horizontal rule to divide
</p>
sections
<hr/>
 <hr/> draws line across window
<h1>Major heading 2</h1>  <hr width="50%" /> sets width
<p>
Here is some more text.
 <hr size=10 /> sets thickness
</p>
</body>

</html> view page in browser 5


Aligning text
<html>
<!-- Dave Reed page04.html
<!-- Demo web page
1/16/04 -->
-->
can specify how
elements should be
<head>
<title>Text Alignment</title> aligned (default is
</head>
left-justified)
<body>  utilize STYLE
<h1 style="text-align:center">Centered Heading</h1> attribute of tag
<p>
Here is some left-justified text
(which is the default in HTML).
</p>
to justify more than
<p style="text-align:center">
Here is some centered text. one element as a
</p> group, use DIV tags
<div style="text-align:right">
 ell elements enclosed
<h2>Right-justified Heading</h2> in DIV are formatted
<p>Here is some right-justified text.</p> similarly
</div>
</body>

</html>

view page in browser 6


Text styles
<html> can specify styles for fonts
<head>
<title>Text Styles</title>  <b>… </b> specify bold
</head>  <i>… </i> specify italics
 <tt>… </tt> specify typewriter-like
<body> (fixed-width) font
<p>
Text can be emphasized using
<b>bold</b>, <i>italics</i>, or even
 <big>… </big> increase the size of
<big>resizing</big>. <br/> the font
The typewriter font is good for  <small>… </small> decrease the
displaying code: size of the font
<tt>sum = sum + i;</tt> <br />
And remember: <span style="color:red">
 <sub>… </sub> specify a subscript
<small>2<sup>10</sup></small> =
1024</span>
 <sup>… </sup> a superscript
</p>
</body>  <p style="color:red">…</p>
for paragraphs
</html>  <span style="color:blue">
…</span> for inline text

view page in browser Note: if elements are nested, the order of


opening/closing is important! (LIFO)
7
More text grouping
<html>
<!-- Dave Reed page06.html 1/16/04 -->  <pre>…</pre> specify text that is to
be displayed as is (line breaks and
<head> spacing are preserved)
<title>More Text Grouping</title>
</head>
useful for code or whenever you want text
<body> to fit a specific layout
<p>
<pre>
for (i = 0; i < 10; i++) {
sum = sum + i;  <blockquote>…</blockquote>
}
</pre>
specify text that is to be indented on
</p> both margins
<p> useful for quotations or for indenting text
Eagleson's Law states that: in subsections
<blockquote>
Any code of your own that you haven't
looked at for six or more months
might as well have been written by
someone else.
</blockquote>
</p>
</body> view page in browser
</html> 8
Lists
<html>
<!-- Dave Reed page07.html 1/16/04 -->
there are 3 different types of list
<head> elements
<title>Simple Lists</title>
</head>
 <ol>…</ol> specifies an ordered list
<body> (using numbers or letters to label each
<p> list item)
<ol>
<li> identifies each list item
<li>First thing.
<li>Second thing.
<li>Third thing.
can set type of ordering, start index
</ol>
</p>
 <ul>…</ul> specifies unordered list
<p> (using a bullet for each)
<dl> <li> identifies each list item
<dt>HTML
<dd>HyperText Markup Language
<dt>HTTP
<dd>HyperText Transfer Protocol  <dl>…</dl> specifies a definition list
</dl> <dt> identifies each term
</p> <dd> identifies its definition
</body>
view page in browser
</html>
9
Hyperlinks
<html> perhaps the most important HTML
<!-- Dave Reed page08.html 1/16/04 --> element is the hyperlink, or
<head> ANCHOR
<title>Hyperlinks</title>
</head>  <a href="URL">…</a>
<body>
where URL is the Web address of the
<p> page to be displayed when the user
<a href="http://www.creighton.edu"> clicks on the link
Creighton University</a>
<br> if the page is accessed over the Web,
<a href="page07.html" target="_blank"> must start with http://
Open page07 in a new window</a>
</p> if not there, the browser will assume it is
</body> the name of a local file

</html>
 <a href="URL"
target="_blank">…</a>
view page in browser
causes the page to be loaded in a new
window

10
Hyperlinks (cont.)
<html>
<!-- Dave Reed page09.html 1/16/04 -->
for long documents, you can even
have links to other locations in that
<head>
<title>Internal Links in a Page</title>
document
</head>
 <a name="ident">…</a>
<body>
<p align="center"> where ident is a variable for identifying
[ <a href="#HTML">HTML</a> | this location
<a href="#HTTP">HTTP</a> |
<a href="#IP">IP</a> |
<a href="#TCP">TCP</a> ]
</p>  <a href="#ident">…</a>
<p>
Computer acronyms: will then jump to that location within the
<dl> file
<a name="HTML"></a><dt>HTML
<dd>HyperText Markup Language
<a name="HTTP"></a><dt>HTTP  <a href="URL#ident">…</a>
<dd>HyperText Transfer Protocol
<a name="IP"></a><dt>IP can jump into the middle of another file
<dd>Internet Protocol just as easily
<a name="TCP"></a><dt>TCP
<dd>Transfer Control Protocol
</p>
</body>
</html> view page in browser 11
Images
can include images using IMG
 by default, browsers can display GIF and JPEG files
 other image formats may require plug-in applications for display

<img src="filename" alt="alternate text" />

again, if file is to be accessed over the Web, must start with http:// (if not, will assume local file)

<html>
<!-- Dave Reed page10.html 1/16/04 -->

<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> view page in brow
</html> ser 12
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>
<!-- Dave Reed page11.html 1/16/04 -->

<head>
<title>Tables</title> <table>…</table> specify a table
</head>
element
<body>
<table> <tr>…</tr> specify a row in the table
<tr>
<td>foo</td> <td>bar</td>
</tr> <td>…</td> specify table data (i.e., each
<tr> column entry in the table)
<td>bizbaz</td> <td>booboo</td>
</tr>
</table>
</body>
</html> view page in browser 13
Layout in a table
can have a border on tables using
<html>
<!-- Dave Reed page12.html 1/16/04 --> the BORDER attribute
<head> <table border=1>
<title>Table Layout</title>
</head> increasing the number makes the border thicker

<body>
<table border=1>
can control the horizontal & vertical
<tr align="center"> layout within cells
<td>foo<br>foo</td>
<td valign="top">bar</td> <td align="center">
</tr>
<tr> <td align="right">
<td>bizbaz</td>
<td>booboo</td> <td valign="top">
</tr>
</table> <td valign="bottom">
</body>
</html>
can apply layout to an entire row
view page in browser
<tr align="center">
<tr valign="top">

14
Table width
<html>
<!-- Dave Reed page13.html 1/16/04 --> by default, the table is sized to fit
<head>
the data
<title>Table Width</title>
</head>
can override & specify the width of a
<body>
<table width="100%">
table relative to the page
<tr> <table width="60%">
<td>left-most
<td align="right">right-most</td>
</tr>
</table>
</body>
useful for page footer –
</html> set table width to 100%
1st column: left-justified
2nd column: right-justified
view page in browser

15
Other table options
<html> can control the space between
<!-- Dave Reed page14.html 1/16/04 -->
cells & margins within cells
<head> <table cellspacing=5>
<title>Table Formatting</title>
</head> <table cellpadding=5>

<body>
<table border=1 cellspacing=4 cellpadding=8>
can add headings
<tr> <th> is similar to <td> but displays
<th>HEAD1</th> <th>HEAD2</th> <th>HEAD3</th> heading centered in bold
</tr>
<tr>
<td>one</td> <td>two</td> <td>three</td> can have data that spans more
</tr> than one column
<tr>
<td rowspan=2 align="center"> four </td> <td colspan=2>
<td colspan=2 align="center"> five </td>
</tr>
<tr> similarly, can span more than one
<td> six </td> <td> seven </td> row
</tr>
</table> <td rowspan=2>
</body>
</html>
view page in browser
16
Example Web page revisited

consider the CSC 551 Home Page again

 section names, times, and rooms are aligned (3-column table)

 office hours are aligned, with "Office hours:" to the left (2-column table)

 grading categories in a table with a border

 class schedule in a big table


• week number centered in first column
• weekly topic displayed as a table within a table
• spring break & final exam are multi-column

 file name and date are displayed as footer

17
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

can divide vertically


<html> <frameset cols="50%,50%">
<!-- Dave Reed page15.html 1/16/03 -->

<frameset cols="*,*"> or, horizontally


<frame src="page01.html">
<frame src="page02.html"> <frameset rows="30%,*,*">
</frameset>
* causes the browser to divide the
</html> remaining space evenly

view page in browser


by default, each frame scrollable
• can drag the border to resize
• can hide the border with frameset
attribute frameborder=0
18
Frame controversy
frames are probably the most controversial HTML feature
 some people love them, some people hate them

2 reasonable uses for frames


 as a navigational aid:
can divide the screen into a static menu frame and the main frame for navigating a
site
e.g., www.creighton.edu/~davereed

 as a means of separating program input from output:


can divide the screen into a static man input form frame and the main frame for
displaying output
e.g., www.creighton.edu/~davereed/csc551/JavaScript/story.html

19
Menu frame
to create a menu, need to be able to <html>
<!-- Dave Reed menu16.html 1/16/04 -->
direct links to the main frame <head>
 name the frames in the FRAMESET <title>Menu of Demos</title>
 specify the frame name as TARGET </head>
in the link
<body>
 specify _top as target to return to Links to demo pages
top level of browser
<p>
<a href="page01.html"
<html> target="main">Demo 1</a><br/>
<!-- Dave Reed page16.html 1/16/04 --> <a href="page02.html"
target ="main">Demo 2</a><br/>
<head> <a href="page03.html"
<title>Demo Browser</title> target ="main"> Demo 3</a><br/>
</head> <a href="page04.html"
target ="main"> Demo 4</a><br/>
<frameset cols="30%,*"> <a href="page05.html"
<frame src="menu16.html" name="menu"> target ="main"> Demo 5</a><br/>
<frame src="page01.html" name="main"> <a href="page06.html"
</frameset> target ="main"> Demo 6</a><br/>
<a href="http://www.creighton.edu"
</html> target="_top" >Creighton</a>
</p>
view page in browser </body>
</html> 20
Content vs. presentation
most HTML tags define content type, independent of presentation
 exceptions?

style sheets associate presentation formats with HTML elements


 CSS1: developed in 1996 by W3C
 CSS2: released in 1998, but not fully supported by browsers

 HTML style sheets are known as Cascading Style Sheets, since can be defined at
three different levels
1. inline style sheets apply to the content of a single HTML element
2. document style sheets apply to the whole BODY of a document
3. external style sheets can be linked and applied to numerous documents

lower-level style sheets can override higher-level style sheets

21
Inline style sheets Using the style attribute, can
specify presentation style for a
<html>
<!-- Dave Reed page17.html 1/16/04 -->
single HTML element
<head>  within tag, list sequence of
<title>Inline Style Sheets</title> property:value pairs
</head>
font-family:Courier,monospace
<body>
font-style:italic
<p style="font-family:Arial,sans-serif;
text-align:right">This is a font-weight:bold
right-justified paragraph in a sans serif font-size:12pt font-size:large font-size:larger
font (preferably Arial), with some
<span style="color:green">green text</span>. color:red color:#000080
</p> background-color:white
<p>And <a style="color:red;
text-decoration:underline
text-decoration:none;
font-size:larger;"
text-decoration:none
href="page01.html">here</a> text-align:left text-align:center
is a formatted link. text-align:right text-align:justify
</p> vertical-align:top vertical-align:middle
</body> vertical-align:bottom
</html>
text-indent:5em text-indent:0.2in
view page in browser
22
Inline style sheets (cont.)
<html>
<!-- Dave Reed page18.html 1/16/04 --> more style properties & values
<head>
<title>Inline Style Sheets</title>
margin-left:0.1in margin-right:5%
</head>
margin:3em
<body> padding-top:0.1in padding-bottom:5%
<p>Here is an image padding:3em
<img src="reed.gif" alt="Dave Reed"
style="margin-left:0.3in;
margin-right:0.3in; border-width:thin border-width:thick
vertical-align:middle; border-width:5
border-style:double; border-color:red
border-color:yellow"> border-style:dashed border-style:dotted
embedded in text. border-style:double border-style:none
</p>

<ol style="list-style-type:upper-alpha">
whitespace:pre
<li> one thing
<li> or another list-style-type:square
<ul style="list-style-type:square; list-style-type:decimal
whitespace:pre"> list-style-type:lower-alpha
<li> with this list-style-type:upper-roman
<li> or that
</ul>
</ol>
</body> 23
</html> view page in browser
Inline style sheets (cont.)
<html>
<!-- Dave Reed page19.html 1/16/04 --> style sheets can be applied to
<head> tables for interesting effects
<title> Inline Style Sheets </title>
</head>

<body>
<table style="font-family:Arial,sans-serif">
<caption style="color:red;
font-style:italic;
text-decoration:underline">
Student data. </caption>
<tr style="background-color:red">
<th> name </th> <th> age </th>
</tr>
<tr>
<td> Chris Smith </td> <td> 19 </td>
</tr>
<tr>
<td> Pat Jones </td> <td> 20 </td>
</tr>
<tr>
<td> Doogie Howser </td> <td> 9 </td>
</tr>
</table>
</body>
</html>
view page in browser
24
Document style sheets
inline style sheets apply to individual elements in the page
 can lead to inconsistencies as similar elements are formatted differently
e.g., might like for all H1 elements to be centered

 inline definitions mix content & presentation


 violates the general philosophy of HTML

alternatively, document style sheets allow for a clean separation of content


and presentation
 style definitions are placed in the HEAD of the page (within STYLE tags)

 can apply to all elements, or a subclass of elements, throughout the page

25
Document style sheets
<html>
<!-- Dave Reed page20.html 1/16/04 --> document style sheets ensure that
<head> similar elements are formatted
<title>Document Style Sheets</title>
<style type="text/css">
similarly
h1 {color:blue;  can even define subclasses of
text-align:center} elements and specify formatting
p.indented {text-indent:0.2in}
</style> p.indented defines subclass of
</head> paragraphs
• inherits all defaults of <p>
<body> • adds new features
<h1>Centered Title</h1>
to specify this newly defined class, place
<p class="indented">This paragraph will
have the first line indented, but
class="ID" attribute in tag
subsequent lines will be flush.</p>

<p>This paragraph will not be indented.


</p>
note how "clean" the BODY is
<h1>The End</h1>

</body>
</html> view page in browser 26
Document style sheets (cont.)
<html>
<!-- Dave Reed page21.html 1/16/04 -->
document style sheets are
<head>
<title> Inline Style Sheets </title> especially useful in
<style type="text/css">
table {font-family:Arial,sans-serif}
formatting tables
caption {color:red;
font-style:italic;
text-decoration:underline}
th {background-color:red}
effectively separates
</style> content from presentation
</head>

<body>
<table>
<caption> Student data. </caption>
what if you wanted to right-
<tr><th> name </th> <th> age</th></tr> justify the column of
<tr><td> Chris Smith </td> <td> 19 </td></tr>
<tr><td> Pat Jones </td> <td> 20 </td></tr> numbers?
<tr><td> Doogie Howser </td> <td> 9 </td></tr>
</table>
</body> what if you changed your
</html>
mind?
view page in browser
27
Pseudo-elements
<html>
<!-- Dave Reed page22.html 1/16/04 --> pseudo-elements are used to
address sub-parts of elements
<head>
<title>Title for Page</title>
<style type="text/css">
 can specify appearance of link in
a {color : red; various states
:visited :active :hover
text-decoration : none;
font-size : larger}  can specify format of first line in page
a:visited {color : black} or paragraph
a:active {color : orange} :first-line
a:hover {color : blue}
p:first-letter {font-size : large;  can specify format of first letter in
color : white; page or paragraph
background-color : darkblue} :first-letter

</style>
</head>
Danger : changing the look of
<body>
<p>Welcome to my Web page. I am so familiar elements is confusing
happy you are here.
</p>
<p>Be sure to visit Careful : current browsers do not
<a href="http://www.cnn.com">CNN</a> support all CSS2 features
for late-breaking news.
</p>
</body> view page in browser 28
</html>
External style sheets
modularity is key to the development and reuse of software
 design/implement/test useful routines and classes
 package and make available for reuse

 saves in development cost & time


 central libraries make it possible to make a single change and propogate

external style sheets place the style definitions in separate files


 multiple pages can link to the same style sheet, consistent look across a site
 possible to make a single change and propagate automatically

 represents the ultimate in content/representation separation

29
Modularity & style sheets
<html> <!-- myStyle.css Dave Reed 1/16/04 -->
<!-- Dave Reed page23.html 1/16/04 -->
h1 {color : blue; text-align : center}
p.indented {text-indent:0.2in}
<head>
<title>Title for Page</title>
<link rel="stylesheet"
type="text/css"
href="myStyle.css"
title="myStyle">
ideally, the developer(s) of a Web site
</head> would place all formatting options in an
<body> external style sheet
<h1>Centered Title</h1>

<p class="indented">This paragraph will all Web pages link to that same style
have the first line indented, but
subsequent lines will be flush.</p> sheet for a uniform look
<p>This paragraph will not be indented.
</p>  simplifies Web pages since only need to
specify structure/content tags
<h1>The End</h1>

</body>
</html>
view page in browser 30
Web rules of thumb
HTML provides for lots of neat features,
but just because you can add a feature doesn't mean you should!

don't add features that distract from the content of the page

 use color & fonts sparingly and be careful how elements fit together
e.g, no purple text on a pink background, no weird fonts

 use images only where appropriate


e.g., bright background images can make text hard to read
e.g., the use of clickable images instead of buttons or links can slow access
 don't rely on window or font size for layout
e.g., font size may be adjusted by viewer, window constrained
 don’t be annoying
e.g., no pop-up windows, excessive advertising, silly music

 break large document into smaller or provide a menu (either internal or frame)
 stick to standard features and test using both IE and Netscape
 utilize style sheets to make changes easy & ensure consistency
31

You might also like