HTML Notes
HTML Notes
HTML
INTRODUCTION TO HTML
HTML is a Hyper Text Markup Language which is used to create Web pages. It is
text based simple Language. It is not a case sensitive language.
WEB PAGE
It is an interactive document that stores information that can be viewed on a global
network of computers.
ESSENTIALS
To prepare web pages and write HTML documents, the following things are
required.
a) Window based computer system with any text editor like Notepad,
Notepad ++.
b) Internet Explorer.
<HTML>
<HEAD>
<TITLE>
……………………
……………………
</TITLE>
</HEAD>
Page | 2
<BODY>
…………….
</BODY>
</HTML>
Tags can be written in any case, upper case, lower case or mixture of both. The
<head> tag is used for providing header information. This tag is a container tag. The
document title is written in <title> tags.
Body tag is used to represent the body of the document. It is a container tag. The
whole text to be represented as body of the document is written in between
<body> and </body> tags.
Heading <H1> to <H6> This tag is used to divide the text that we type into
Levels different sections using Heading Levels which indicate a
different Size and Style for each level.
Paragraph <P> This Tag is used to indicate a break and space between
Break one paragraph and the other.
Line Break <Br> This Tag is used to give a Line Break so that the next
sentence is typed on the new line.
Numbered or <ol> This Tag is used to create a Numbered List which has a
Ordered List certain sequence or order.
Bullet or <Ul> This Tag is used to create Bulleted List which doesn’t have
unordered List special order with marks before the text.
List Items <Li> This Tag is used to type the contents or each item of the
Bulleted or Numbered List.
BOLD TAG
You can create the bold text in the web page by using <b> or <strong> tag.
<I> Italic Text </I> <em> emphasized text </em> <var> text </var>
Text
The attribute text is used to choose text color in the web page
<body text=”name of color”>
You have to write the name of the color to be given to the text of the web page.
<body text=”pink”>
The above command selects the pink color to the text of the web page.
Topmargin
The attribute sets the top margin of the web page. The value of the topmargin is
given in pixels.
<body topmargin=”50”>
The above command will display the text 50 pixels away from the top of the web
page.
Leftmargin
The attribute leftmargin sets the left margin of the text. Its value is also given in
pixels.
<body leftmargin=”50”>
The above command will display text 50 pixels away from the left of the web page.
LISTS
Ordered lists are those lists which have some sequence or serial numbers. For
example 1,2,3,… or a,b,c… etc are ordered lists. These lists are also known as
numbered lists. Ordered lists are created between <ol> and </ol> tags.
(i) Type = “a” for starting list from a,b,c etc. (small letters)
(ii) Type = “A” for starting list from A,B,C etc. (capital letters)
(iii) Type = “i” for starting list from roman numbers.
(iv) Type = “1” for starting list from Numbers. Etc.
Page | 6
For example:
<body>
INPUT DEVICES
<ol>
<li> keyboard
<li> mouse
<li> scanner
<li> joystick
</ol>
Unordered lists are those lists which do not have any serial number. A bullet sign is
placed before each item of the lists. An unordered list is created between <ul> and
</ul> tags. Attributes of unordered lists are circle, disc, square.
DEFINITION LIST
Definition list is used to define a word. The word to be defined is used within <dl>
and </dl> tags. Tags <dt> and <dd> are used between the definition list tag. The tag
<dt> is used before the word to be defined whereas <dd> is used for writing
definition of the word.
HORIZONTAL RULERS
Horizontal rulers can be shown in the web pages to identify some portion of the
text in a particular way. For drawing horizontal ruler, <hr> tag is used. The tag <hr>
is an empty tag. It doesn’t require any closing tag.
Note that if you can't view the examples, it's likely that your browser doesn't
support the marquee tag.
Width: how wide the marquee is. This will have a value like 10 or 20%etc.
Height: how tall the marquee is. This will have a value like 10 or 20% etc.
Direction: which direction the marquee should scroll. This will have value
either up, down, left or right.
Behavior: what type of scrolling? This will have value scroll, slide and
alternate.
scrolldelay: how long to delay between each jump. This will have a value like
10 etc.
Scrollamount: how far to jump. This will have a value like 10 etc.
Loop: how many times to loop. The default value is INFINITE, which means
that the marquee loops endlessly.
Bgcolor: background color. This will have any color name or color hex value.
Hspace: horizontal space around the marquee. This will have a value like 10
Page | 8
or 20%etc.
Vspace: vertical space around the marquee. This will have a value like 10 or
20%etc.
CHANGING DIRECTIONS
<marquee direction="left"> your scrolling text goes here </marquee>
<marquee direction="right"> your scrolling text goes here </marquee>
<marquee direction="up"> your upward scrolling text goes here</marquee>
<marquee direction="down"> your downward scrolling text goes here</marquee>
CHANGING BEHAVIOR
<marquee behavior="alternate">your bouncing text goes here</marquee>
<marquee behavior="scroll">your bouncing text goes here</marquee>
<marquee behavior=”slide”> Bounce </marquee>
We can also change the loop (no of times to repeat) of the marquee text by using
loop attribute.
<marquee loop=”3”> Text to repeat the scrolling in three times </marquee>
TABLES
Page | 9
Tables play an important role in displaying data in a web page.
STRUCTURE OF A TABLE
A table is made of rows and columns. The horizontal area is row and vertical area is
column. The intersection of row and column is called a cell. Data is entered in cells.
Four basic elements are needed to create tables. These are table tag, table row,
table data and table heading.
TABLE TAG
The <table> tag begins the table, you place what you want inside and end the table
with the </table> tag. To begin adding contents to your table, you will need the
<tr> and <td> tags. The <tr> stands for table row and the <td> stands for table data,
which is what you will place after this tag. You end a table section with the </td>
tag and each table row with the </tr> tag.
TABLE ROW
The <tr> and </tr> tags are used to draw rows of table. Tr means table row. A row
is a group of cells in horizontal direction.
TABLE DATA
The <td> and </td> tags are used to show data in a table. Td means table data. The
<td> tag defines a standard cell in a HTML table.
TABLE HEADING
The <th> tag defines a header cell in a HTML table.
HTML table has two kinds of cells:
1. Header cells: Contains header information.
2. Standard Cells: Contains Data.
The text in a th element is bold and centered.
TABLE SIZE
We can set the size of the table based on pixels. For example <tr height=”50”> &
Page | 10
<tr width=”30”>. Table width and height can be set by using percentage. For
example width=70%.
TABLE COLOR
The color attribute is used to change the background color of the table. The color
attribute is used with the table tag. The following example shows how to add a
background color for an entire table using generic values of color. <table
bgcolor=”pink”>. We can change the color of the cells in a table too by using color
attribute.
TABLE BORDER
If we do not specify a border attribute the table will be displayed without any
borders. Sometimes this can be useful, but most of the time, we want the borders
to show. To display a table with borders, we will have to use border attribute. For
example <table border=”2”>.
A SAMPLE TABLE
<table border=”2” bgcolor=”pink” width=”80%” height=”40%”>
<tr height=”20%”> <th> Name </th> <th> Class </th> </tr>
<tr> <td> Sameer </td> <td> 12th </td> </tr>
</table>
Table cells can span across more than one column or row. The attributes COLSPAN
("how many across") and ROWSPAN ("how many down") indicate how many
columns or rows a cell should take up.
For example, we might want to create header cells for each department in our
table of names and phone numbers. In this table, the header cells in the first and
fifth rows span across two columns to indicate the department for each group of
Page | 11
names.
ROWSPAN sets how many rows a cell spans. ROWSPAN can get a little confusing
because it requires you to think through how the cell affects the rows after the row
it starts in. It's particularly useful in this situation to add borders to the table during
the design process, even if the table won't ultimately use borders.
This table code creates two header cells which span three rows each:
ANCHOR TAG
HTML anchor <a> tag is also very useful for creating bookmark links. HTML
bookmark tag links help in linking the different parts of a single HTML document.
HTML bookmark tag link navigates the web page to the targeted location of same
or different web page. Name attribute of HTML anchor <a> tag provides the
feature of bookmark links.
<a href=”location of the file”> Click here to go to the next page </a>
TEXT FIELDS
<Form>
First name:
<input type=”text” name=”firstname”> <br>
Last name:
<input type=”text” name “lastname”>
</form>
By using size attribute we can change the text field size of the input element.
<input type=”text” name=”firstname” size=”50”>
We can also put the sample text in the text fields of input element by using value
attribute.
<input type=”text” name=”firstname” size=”50” value=”Sameer”>
PASSWORD FIELD
<input type=”password”> The characters in a password field are marked (shown as
asterisks or circles).
RADIO BUTTONS
Radio buttons let user to select one option from limited number of choices.
<form>
Select sex:
<input type=”radio” name=”sex” value=”male”> Male <br>
<input type=”radio” name=”sex” value=”female”> female <br>
</form>
CHECK BOXES
Check boxes let a user to select one or more options of limited number of choices.
Page | 14
<form>
<input type=”checkbox” name=”vehicle” value=”bike”> I have a bike <br>
<input type=”checkbox” name=”vehicle” value=”Car”> I have a car <br>
</form>
SUBMIT BUTTON
A submit button is used to send form data to a server. The data is sent to the page
specified in the form’s action attribute. The file defined in the action attribute
usually does something with the received input.
<Form>
<input type=”submit” name=”submit” value=”submit”>
</form>