Download presentation
Presentation is loading. Please wait.
1
The Comment tag Many programming languages allow us to write comments in a program Comments are ignored by the computer when processing the program but are useful to humans reading the program text HTML also provides comments They are ignored by browsers but are useful to humans reading HTML specifications
2
Comment tags (contd.) A comment tag is of the form A comment can appear anywhere in a HTML specification They are frequently used to tell people who wrote the specification, when, why, etc.
3
Politics in Ireland Presidents The presidents of Ireland were Douglas Hyde Eamon de Valera
4
Using tags
5
tags tags are used to incorporate pictures into web documents A picture cannot be inserted directly into the HTML spec of a web document, since a HTML spec is a textual spec tags are used to point to pictures that we want to appear in a web document
6
tags (contd.) The tag is a structured tag -- it has attributes The SRC attribute is used to point to the picture to be included
7
A simple web document containing a picture
10
Of course, we can have text with the pictures
13
A document
16
The ALIGN attribute In early versions of HTML, IMG tags used to have an ALIGN attribute for specifying how to align pictures relative to neighbouring text This was, therefore, a rendering attribute DO NOT USE this attribute –NEVER use rendering attributes We will see how to achieve rendering effects more cleanly when we meet Style Sheets
17
Specifying Image sizes The tag has further ATTRIBUTES –the WIDTH and –the HEIGHT which specify the size of the displayed version of an image, in units called “pixels”
18
Suez
20
Colour of the background It would be preferable if you could ignore such rendering features as the colour of the background Unfortunately, when you start using pictures, you cannot, since pictures have colour and you have to consider how clearly an image will show up against the background
21
Background colour (contd.) For example, consider how the last document we specified would appear in both Netscape Navigator and Microsoft Explorer
24
Background colour (contd.) In Netscape, the images show up clearly against the default background colour, which is white In Explorer, the largely-grey images do not contrast so well with the grey-ish background
25
Background colour (contd.) We can specify the background colour we want Early versions of HTML provided a BGCOLOR attribute in the tag However this is a rendering attribute and SHOULD NOT BE USED We will see how to do it more cleanly when we meet style sheets
26
Background PATTERNS We can also ask the browser to use a repeated version of some image as a background This should be done with care, because –it can lead to unreadable documents –it adds to the length of time it takes to download a document over the Internet
27
Background PATTERNS Early versions of HTML provided an attribute in the tag for this purpose Again, as with all rendering attributes, DO NOT USE IT We will see how to do achieve the same effect more cleanly when we meet style sheets
28
Another kind of list: Definition lists
29
Definition lists: Frequently, we want to have lists of items like this: CPU Central Processor Unit VDU Visual Display Unit IRQ Interrupt ReQuest
30
In other words, we want to have a list in which each member has two parts: –a TERM, whose meaning is to be defined –a DEFINITION of the term
31
HTML provides a tag for this kind of concept: the Definition List tag or tag A list of definitions is delimited by a tag and a tag ….
32
Each item between the and tags has two parts, a term and its definition A term is delimited by and tags, while a definition is delimited by and tags: CPU Central Processing Unit VDU Visual Display Unit IRQ Interrupt ReQuest
33
Example document: Definition List Some Computing Acronyms CPU Central Processing Unit VDU Visual Display Unit IRQ Interrupt ReQuest
35
Another example document: Languages of the World Languages of the World Tok Pisin A Melanesian Creole spoken in the South-western Pacific Hakka One of the languages spoken in Fujien province in China Mon A language spoken in Cambodia Xhosa One of the major languages of South Africa
37
Style Sheets: the right way to specify rendering
38
Structure versus Rendering HTML specifications of documents should contain only information about how a document is structured into logical units such as paragraphs, pictures, lists, etc. HTML specifications should not contain rendering information And yet: –we often want to specify how we want a document rendered
39
Question: How can we specify our own style of rendering without mixing rendering rules inside a document’s logical specification?
40
Answer: We should use Style sheets
41
Style sheets A style sheet contains a set of rendering specifications We can apply a style sheet to a HTML document specification in order to change the appearance of the document when it is rendered by a browser
42
A simple style sheet This style sheet specifies that all items in any document to which the style sheet is applied should be printed in red H1 { COLOR : red}
43
Storing style sheets: We can store style sheets in files with the extension “.css” For example, the style sheet H1 { COLOR : red} could be stored in a file called style1.css
44
Applying style sheets We apply a style sheet in a.css file to a document in a.htm file by calling the.css file in the part of the.htm file: … <LINK REL=STYLESHEET TYPE=“text/css” HREF=“style1.css” > Wars of the 20th Century
46
Multiple usage of a style sheet: We can apply a style sheet which is stored in a.css file to many documents This HTML spec uses style1.css as well: … <link rel=“stylesheet” type=“text/css” href=“style1.css” > Tourist Attractions of the World
48
A more sophisticated style sheet Specifying styles for items as well as items
49
style2.css h1 {color : red} p {color : blue}
50
wars.htm … Wars of the 20th Century The century just coming to an end was one of the bloodiest on record...
52
Several H1 style attributes h1 {color : red; font-size : 50} p {color : blue}
54
Another H1 style attribute H1 {COLOR : red; FONT-SIZE : 50 ; FONT-FAMILY : arial} P {COLOR : blue}
56
We can, of course, specify styles for all levels of headings Consider a document which has H2 as well as H1 headings
57
wars2.htm
58
style2.css This first style-sheet does not specify anything for the H2 headings: H1 {COLOR : red ; FONT-SIZE : 20 ; FONT-FAMILY : arial} P {COLOR : blue} So, as we see on the next slide, H2 headings have the default style
59
Applying style2.css to wars2.htm
60
style3.css H1 {COLOR : red ; FONT-SIZE : 20 ; FONT-FAMILY : arial} H2 {COLOR : green} P {COLOR : blue}
61
Applying style3.css to wars2.htm
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.