35
1 Mastering the Internet Mastering the Internet and HTML and HTML Lists and List Tags

1 Mastering the Internet and HTML Lists and List Tags

Embed Size (px)

Citation preview

Page 1: 1 Mastering the Internet and HTML Lists and List Tags

1

Mastering the Internet and Mastering the Internet and HTMLHTML

Lists and List Tags

Page 2: 1 Mastering the Internet and HTML Lists and List Tags

2

OutlineOutline

Goal Objectives Introduction Unordered list Ordered list Definition list Nested lists

Formatting via lists Nontext list items Tutorials FAQs Summary Exercises/Homework

Page 3: 1 Mastering the Internet and HTML Lists and List Tags

3

GoalGoal

This chapter covers lists, their use in Web

pages, their types, and their tags. It also

covers nested lists, nontraditional (nontext)

list items, and formatting via lists.

Page 4: 1 Mastering the Internet and HTML Lists and List Tags

4

ObjectivesObjectives

IntroductionTypes of listsFormatting via listsNontext list itemsHTML tags for lists

Page 5: 1 Mastering the Internet and HTML Lists and List Tags

5

IntroductionIntroduction

Lists allow Web authors to organize and indent text in Web pages

Lists could be used to describe components of a product, steps of a procedure, tasks of a plan, and organizational/hierarchical structures

HTML supports three types of lists: unordered, ordered, and definition. The difference between these types comes in their rendering

Page 6: 1 Mastering the Internet and HTML Lists and List Tags

6

Unordered listsUnordered lists

Unordered lists itemize information whose order is not important

Browsers use one of three symbols to display list items: disk (filled circle), square, or circle

The <UL> tag creates unordered lists. The tag must close to define the end of the list

The <LI> tag defines list items of a list. The tag is used inside the <UL> tag as many times as there are list items. Its most common attribute is TYPE, which specifies the display symbol of list items.

(Cont’d)

Page 7: 1 Mastering the Internet and HTML Lists and List Tags

7

Unordered listsUnordered lists Example 8.1 Unordered lists (figures 8.1 and 8.2)(removed top part of the tags)<! List uses default list symbols>Here is my first unordered list<UL> <LI>First list item <LI>Second list item <LI>Third list item <LI>Fourth list item</UL><! List controls list symbols>Here is my second unordered list<UL> <LI TYPE = "disc">List item using the disc symbol <LI TYPE = "circle">List item using the circle symbol <LI TYPE = "square">List item using the square symbol <LI>List item using no TYPE attribute</UL></BODY></HTML> (Cont’d)

Page 8: 1 Mastering the Internet and HTML Lists and List Tags

8

Figure 8.1 Netscape rendering Figure 8.2 MS IE rendering

Page 9: 1 Mastering the Internet and HTML Lists and List Tags

9

Ordered listsOrdered lists Ordered lists itemize information whose order is

important( Browsers use one of three styles to display list items:

Arabic numbers (1, 2, …), Latin letters (A, a, B, b, …), or Roman numerals (I, i, II, ii, …)

The <OL> tag creates ordered lists. The tag must close to define the end of the list

The <LI> tag defines list items of a list. The tag is used inside the <UL> tag as many times as there are list items. Its most common attribute is TYPE, which specifies the display style of list items. (Cont’d)

Page 10: 1 Mastering the Internet and HTML Lists and List Tags

10

Ordered listsOrdered lists Example 8.2 Ordered lists

(removed top part of the tags)<! List uses default list numbers>This ordered list uses Arabic (default) numbers<OL> <LI>First list item <LI>Second list item <LI>Third list item <LI>Fourth list item</OL> <! List uses uppercase Latin letters>This ordered list uses uppercase Latin letters<OL> <LI TYPE="A">List item using uppercase

Latin letter <LI>List item using uppercase Latin letter <LI>List item using uppercase Latin letter <LI>List item using uppercase Latin letter</OL>

<! List uses lowercase Roman numerals>This ordered list uses lowercase Roman

numerals<OL> <LI TYPE = "i">List item using lowercase

Roman numeral <LI>List item using lowercase Roman

numeral <LI>List item using lowercase Roman

numeral <LI>List item using lowercase Roman

numeral</OL></BODY></HTML>

(figures 8.1 and 8.2)

(Cont’d)

Page 11: 1 Mastering the Internet and HTML Lists and List Tags

11Figure 8.3 Netscape rendering Figure 8.4 MS IE rendering

Page 12: 1 Mastering the Internet and HTML Lists and List Tags

12

Definition listsDefinition lists

Definition lists define terms A definition list consists of term/definition pairs The <DL> tag creates definition lists. The tag

must close to define the end of the list The <DT> and <DD> tags define the term and

definition respectively. These tags are used inside the <DL> tag as many times as there are list items.

(Cont’d)

Page 13: 1 Mastering the Internet and HTML Lists and List Tags

13

Definition listsDefinition lists Example 8.3 Definition lists<HTML><HEAD><TITLE>A Web page with definition

lists</TITLE></HEAD><BODY><H2><B><CENTER><FONT COLOR="blue">Web page with two

definition lists</FONT></CENTER> </B></H2>

This definition list uses DT/DD pairs.<DL> <DT>Term1 <DD>Here is the definition of the first

term <DT>Term2 <DD>Here is the definition of the second

term <DT>Term3 <DD>Here is the definition of the third

term</DL>

<! List uses DT, DT, DT followed by DD, DD, DD>

This definition list uses DT, DT, DT followed by DD, DD, DD.

<DL> <DT>Term1 <DT>Term2 <DT>Term3 <DD>Here is the definition of the first

term <DD>Here is the definition of the

second term <DD>Here is the definition of the third

term</DL></BODY></HTML>

(figure 8.5) (Cont’d)

Page 14: 1 Mastering the Internet and HTML Lists and List Tags

14Figure 8.5 Definition lists

Page 15: 1 Mastering the Internet and HTML Lists and List Tags

15

Nested listsNested lists

Lists may be nested to represent multiple levels of hierarchies

The three types of lists (unordered, ordered, and definition) may be nested together

When we nest lists, we make one or more item of a list an entire new list

There is no limit on the levels of nesting

(Cont’d)

Page 16: 1 Mastering the Internet and HTML Lists and List Tags

16

Nested listsNested lists Example 8.4 Nested lists<<HTML><HEAD><TITLE>A Web page

with nested lists</TITLE></HEAD><BODY><H2><B><CENTER><FONT

COLOR="blue">Web page with three nested lists</FONT></CENTER></B></H2>

<! List uses default list symbols>Here is my three-level nested list<UL> <LI>First-level list item 1 <LI>First-level list item 2

<OL> <LI>Second-level list item 1 <LI>Second-level list item 2 <LI>Second-level list item 3

<UL> <LI>Third-level list item 1 <LI>Third-level list item 2 <LI>Third-level list item3 </UL>

<LI>Second-level list item 4 </OL>

<LI>First-level list item 3 <DL>

<DT>Term1 <DD>Definition Term 1 <DT>Term2 <DD>Definition of Term 2 <DT>Term3 <DD>Definition of Term 3

</DL> <LI>First-level list item 4</UL></BODY></HTML>

(figure 8.6) (Cont’d)

Page 17: 1 Mastering the Internet and HTML Lists and List Tags

17Figure 8.6 Nested lists

Page 18: 1 Mastering the Internet and HTML Lists and List Tags

18

Formatting via listsFormatting via lists

Web authors may list tags to format Web pages

List tags are used to indent textThe tags that produce indentation effects

are <UL>, <OL>, and <DD>

(Cont’d)

Page 19: 1 Mastering the Internet and HTML Lists and List Tags

19

Formatting via list tagsFormatting via list tags Example 8.5 Formatting via list

tags (shortened)<! Using the DT tag does not indent text><FONT COLOR = "red">Using the DT

tag does not indent text</FONT><DT>This text is indented by a DT tag<DT>This text is indented by a DT tag<! Using the DD tag indents text once><FONT COLOR = "red">Using the DD

tag indents text once</FONT><DD>This text is indented by a DD tag<DD>This text is indented by a DD tag<! Nesting the UL and the DD tags

indents text twice><FONT COLOR = "red">Nesting the

UL and the DD tags indents text twice</FONT>

<UL><DD>This text is indented by<DD>a UL tag and a DD tag.<DD>This text is indented by<DD>a UL tag and a DD tag.</UL><! Nesting the UL tag 5 times indents text

5 times><P><UL><UL><UL><UL><UL>

This text is indented by<BR>

nesting five UL tags. </UL></UL></UL></UL> </UL></BODY></HTML>

(figure 8.7) (Cont’d)

Page 20: 1 Mastering the Internet and HTML Lists and List Tags

20

Figure 8.7 Formatting via list tags

Page 21: 1 Mastering the Internet and HTML Lists and List Tags

21

Nontext list itemsNontext list items Items of a list are traditionally text HTML supports nontext list items such as

hyperlinks, images, video, audio, etc. Example 8.6 Nontext list items<HTML><HEAD><TITLE>Non-text list items</TITLE></HEAD><BODY><H2><B><CENTER><FONT COLOR="blue">Creating nontext list

items</FONT></CENTER></B></H2>Here are my nontext list items<! Create a traditional list> (Cont’d)

Page 22: 1 Mastering the Internet and HTML Lists and List Tags

22

Nontext list itemsNontext list items<P> <FONT COLOR = "red">This is a traditional list</FONT><UL> <LI>Traditional list item

<LI>Traditional list item <LI>Traditional list item

</UL><! Create a list with hyperlink items> <P><FONT COLOR = "red">List with hyperlinks</FONT><OL> <LI><A HREF = "http://www.neu.edu">Northeastern University</A>

<LI><A HREF = "http://www.prenhall.com">Prentice Hall publishing</A> <LI><A HREF = "http://www.altavista.com">Use a search engine</A>

</OL><! Mix text and non-text list items> <P><FONT COLOR = "red">Mix text and non-text list items</FONT><UL> <LI TYPE= "square">Traditional list item

<LI><A HREF = "Example8.1.html">Example 8.1 Web page</A> <LI>Traditional list item <LI><A HREF = "Example8.2.html">Example 8.2 Web page</A>

</UL> </BODY> </HTML> (figure 8.8) (Cont’d)

Page 23: 1 Mastering the Internet and HTML Lists and List Tags

23

Figure 8.8 Nontext list items

Page 24: 1 Mastering the Internet and HTML Lists and List Tags

24

TutorialsTutorialsTutorial 8.6.1 A definition list formarketing (top tags are not shown)<! Use a DL list><DL>

<DT><FONT COLOR = "red">Great value</FONT><DD>For as little as $50 a month, you have access to 10 sports programs

which include swimming, tennis, racket ball and family programs.<DT><FONT COLOR = "red">Easy enrollment</FONT>

<DD>All it takes is a phone call. No application to fill or history to give. Call us 8:00 a.m. - 10:00 p.m.<DT><FONT COLOR = "red">Access to membership</FONT>

<DD>You get to meet over 500 members in our monthly parties. Parties are fun for everyone including children.<DT><FONT COLOR = "red">Friendly service</FONT>

<DD>Our courteous staff are available to help you with any of your needs or to answer your questions.

</DL></BODY></HTML>

Page 25: 1 Mastering the Internet and HTML Lists and List Tags

25

TutorialsTutorialsTutorial 8.6.2 A definition list formarkup (shortened from the top)<! Use a DL list><DL>

<DT><FONT COLOR = "red">Student</FONT><DD>Excuse me Professor; I have a question.

<DT><FONT COLOR = "red">Professor</FONT><DD>Certainly; what is the question?

<DT><FONT COLOR = "red">Student</FONT><DD>How can you change text color in HTML?

<DT><FONT COLOR = "red">Instructor</FONT><DD>You can use the FONT tag or style sheets.

<DT><FONT COLOR = "red">Student</FONT><DD>Thank you Professor.<DT><FONT COLOR = "red">Professor</FONT><DD>You are welcome.

</DL></BODY></HTML>

Page 26: 1 Mastering the Internet and HTML Lists and List Tags

26

TutorialsTutorials Tutorial 8.6.3 Hierarchical

structure (shortened from top)<TITLE>Organization structure</TITLE></HEAD><BODY><H2><B><CENTER><FONT COLOR

="blue">Organization structure of a college</FONT></CENTER></B></H2>

<P> Here is the structure of a college in a university

<UL><LI>Dean's office

<UL> <LI TYPE = "square">Dean <LI>Associate dean <LI>Assistant dean <LI>Staff

<OL> <LI>Staff 1 <LI>Staff 2

<LI>Staff 3</OL>

</UL><LI>Department

<OL> <LI>Chairman <LI>Associate chairman <LI>Faculty <UL>

<LI>Group 1 <LI>Group 2 <LI>Group 3</UL>

<LI>Staff <LI>Graduate students <LI>Undergraduate students</OL>

</UL></BODY></HTML>

(figure 8.11) (Cont’d)

Page 27: 1 Mastering the Internet and HTML Lists and List Tags

27

Figure 8.11 Organization structure

Page 28: 1 Mastering the Internet and HTML Lists and List Tags

28

FAQsFAQs Q: Why does my browser not display the lists as I

expect?– A: This is usually due to the improper closing

of the list tags, especially for nested lists. Check all the list tags, and make sure they are closed at the right locations.

Q: How can I get better control of list formatting, for example numbering, indenting, and so forth.?– A: Style sheets allow better control of list

formatting. (Cont’d)

Page 29: 1 Mastering the Internet and HTML Lists and List Tags

29

FAQsFAQs Q: What is the difference between ordered and

unordered lists?– A: Both types are rendered in an identical

manne,r except that browsers use numbers for items of ordered lists and symbols for items of unordered lists.

Q: Can an ordered list continue list numbering automatically from a previous list?– A: No. Ordered lists cannot hide numbering of

some list items, either.

Page 30: 1 Mastering the Internet and HTML Lists and List Tags

30

SummarySummary– Lists allow Web authors to organize and indent text in Web

pages– HTML supports unordered, ordered, and definition lists– Unordered lists itemize information whose order is not

important. The HTML tag is <UL>– Ordered lists itemize information whose order is important.

The HTML tag is <OL>– Definition lists define terms. The HTML tag is <DL>– <UL> and <OL> tags need <LI> tag, while <DL> tag needs

<DT> and <DD> tags to define list items– List items can be any HTML element– Lists may be nested, and may be used for formatting

Page 31: 1 Mastering the Internet and HTML Lists and List Tags

31

ExercisesExercises

Problem 8.1. Create an unordered list of the names of 10 people.– Solution strategy: Follow example 8.1. Use a

text editor to write and debug the HTML code. Use a browser to display the results

(Cont’d)

Page 32: 1 Mastering the Internet and HTML Lists and List Tags

32

<HTML><HEAD><TITLE>Unordered list of ten names</TITLE></HEAD><BODY><FONT SIZE =6 COLOR = "red"><CENTER>A list of ten

names</CENTER></FONT><UL TYPE = "disc">

<LI>Abe Zeid<LI>John Smith<LI>Linda Brown<LI>Adam Jacocbs<LI>Mary Ann Wood<LI>Kathy Shnider<LI>James Hackley<LI>Cindy Smile<LI>George Jones<LI>Sandra Michaels

</UL></BODY></HTML>

Page 33: 1 Mastering the Internet and HTML Lists and List Tags

33

ProblemsProblems

Problem 8.7 Use a definition list for marking up dialogs between three people.– Solution strategy: Use a text editor to write the

HTML code. Use a browser to test it

(Cont’d)

Page 34: 1 Mastering the Internet and HTML Lists and List Tags

34

<HTML><HEAD><TITLE>Using definition List for marking up dialogs between three people</TITLE></HEAD><BODY><H2><B><CENTER><FONT COLOR="blue">Recording three people chat</FONT></CENTER></B></H2>

<P>A conversation takes place in a ski resort<BR>between three skiers. They are advanced skiers.<BR>The conversation is recorded in this Web page.

<DL><DT><FONT COLOR = "red">First skier</FONT>

<DD>How long have you been skiing?<DT><FONT COLOR = "red">Second skier</FONT>

<DD>Since I was 10.<DT><FONT COLOR = "red">Third skier</FONT>

<DD>Since I was 15.<DT><FONT COLOR = "red">Third skier</FONT>

<DD>Ski conditions are excellent today.<DT><FONT COLOR = "red">Second skier</FONT><DD>Sure, they are.<DT><FONT COLOR = "red">First skier</FONT><DD>Let us all hit the slopes.

</DL></BODY></HTML></HTML> (Cont’d)

Page 35: 1 Mastering the Internet and HTML Lists and List Tags

35