Lecture_2
Lecture_2
<html>
<head>
<title>Title of page</title>
</head>
<body> This is my first homepage.
<b>This text is bold</b>
</body>
</html>
The whole document must have <html> as its root
A document consists of a head and a body or frameset
The <title> tag is used to give the document a title, which is
normally displayed in the browser’s window title bar (at the
top of the display)
7
Paragraph Elements
› The <p> tag breaks the current line and inserts a blank line
› The new line gets the beginning of the content of the paragraph
W3C HTML Validation Service
› http://validator.w3.org/file-upload.html
Line breaks
› The effect of the <br /> tag is the same as that of <p>, except for the
blank line, No closing tag!
Example of paragraphs and line breaks
On the plains of hesitation <p> bleach the bones of countless millions <br
/> who, at the dawn of victory <br /> sat down to wait, and waiting, died.
› What is the output of this code??
8
Headings
› Six sizes, 1 - 6, specified with <h1> to <h6>
› 1, 2, and 3 use font sizes that are larger than the default font size
› 4 uses the default size
› 5 and 6 use smaller font sizes
9
All of this font size and font style stuff can be done with
style sheets, but these tags are not yet deprecated
10
Character Entities
› There are some characters that HTML treats as special
characters, so if you want one in a document, it must be coded
› The Most Common Character Entities:
Result Description Entity Name Entity Number
space  
< less than < <
> greater than > >
& ampersand & &
" quotation mark " "
' apostrophe ' '
Horizontal rules
› <hr /> draws a line across the display, after a line break
11
Images are inserted into a document with the <img /> tag
with the src attribute
The <img> tag is empty, which means that it contains
attributes only and it has no closing tag.
src stands for "source". The value of the src attribute is the
URL of the image you want to display on your page.
The syntax of defining an image: <img src="url">
The Alt attribute is used to define an "alternate text" for an
image. The value of the alt attribute is an author-defined
text:
<img src="boat.gif" alt="Big Boat">
In which cases, the ALT attribute will be useful??
14
Unordered Lists
› The list items are marked with bullets (typically small black circles).
› An unordered list starts with the <ul> tag. Each list item starts with
the <li> tag
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
› Here is how it looks in a browser:
Coffee
Milk
Ordered Lists
› The list items are marked with numbers.
› An ordered list starts with the <ol> tag. Each list item starts with the
<li> tag.
<ol> <li>Coffee</li> <li>Milk</li> </ol>
› Here is how it looks in a browser:
1. Coffee
2. Milk
15
Grocery Checklist
<form action = "">
<p>
<input type = "checkbox" name = "groceries"
value = "milk" checked = "checked">
Milk
<br/>
<input type = "checkbox" name = "groceries"
value = "bread"> Bread
<br/>
<input type = "checkbox" name = "groceries"
value= "eggs"> Eggs
</p>
</form>
31