Introduction To HTML
Introduction To HTML
Of Physics
St. Mary’s College
HTML
WHAT IS HTML?
The opening and closing tags use the same command except
the closing tag contains and additional forward slash /
For example, the expression <B> Warning </B> would cause
the word ‘Warning’ to appear in bold face on a Web page
NESTED TAGS
Whenever you have HTML tags within other HTML tags, you
must close the nearest tag first
Example:
<H1> <I> The Nation </I> </H1>
THE <TITLE> TAG
Choose the title of your Web page carefully; The
title of a Web page determines its ranking in
certain search engines
The title will also appear on Favorite lists, History
lists, and Bookmark lists to identify your page
<TITLE/>
<!DOCTYPE html>
<html>
<head>
<title>HTML Elements Reference</title>
</head>
<body>
<h1>This is a heading</h1>
</body>
</html>
TEXT FORMATTING
https://www.w3schools.com/html/html_styles.asp
CHANGING THE FONT
<p>I am normal</p>
<p style="color:red;">I am red</p>
<p style="color:blue;">I am blue</p>
<p style="font-size:50px;">I am big</p>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:powderblue;">This is a
heading</h1>
<p style="background-color:tomato;">This is a
paragraph.</p>
</body>
</html>
5 scrolldelay
This specifies how long to delay between each jump. This will have a value like 10 etc.
6 scrollamount
This specifies the speed of marquee text. This can have a value like 10 etc.
7 loop
This specifies how many times to loop. The default value is INFINITE, which means that the
marquee loops endlessly.
8 bgcolor
This specifies background color in terms of color name or color hex value.
9 hspace
This specifies horizontal space around the marquee. This can be a value like 10 or 20% etc.
10 vspace
This specifies vertical space around the marquee. This can be a value like 10 or 20% etc.
MARQUEE EXAMPLE
<!DOCTYPE html>
<html>
<head>
<title>HTML marquee Tag</title>
</head>
<body>
<marquee>This is basic example of marquee</marquee>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>HTML marquee Tag</title>
</head>
<body>
<marquee direction = "up">This text will scroll
from bottom to up</marquee>
</body>
</html>
META TAG
<head>
<meta charset="UTF-8">
<meta name="description" content="Free Web
tutorials">
<meta name="keywords" content="HTML, CSS,
JavaScript">
<meta name="author" content="John Doe">
<meta name="viewport" content="width=device-
width, initial-scale=1.0">
</head>
ANCHORS
Anchors enable a user to jump to a specific
place on a Web site
Two steps are necessary to create an anchor.
First you must create the anchor itself. Then you
must create a link to the anchor from another
point in the document.
ANCHORS
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
LIST
TagDescription
<ul> Defines an unordered list
<ol> Defines an ordered list
<li> Defines a list item
<dl> Defines a description list
<dt> Defines a term in a description list
<dd> Describes the term in a description list
FRAMES
HTML frames are used to divide your browser window into multiple
sections where each section can load a separate HTML document.
A collection of frames in the browser window is known as a
frameset.
The window is divided into frames in a similar way the tables are
organized: into rows and columns.
<!DOCTYPE html>
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset rows = "10%,80%,10%">
<frame name = "top" src = "/html/top_frame.htm" />
<frame name = "main" src = "/html/main_frame.htm" />
<frame name = "bottom" src = "/html/bottom_frame.htm" />
<noframes><body>Your browser does not support
frames.</body>
</noframes>
</frameset>
</html>
<!DOCTYPE html>
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset cols = "25%,50%,25%">
<frame name = "left" src = "/html/top_frame.htm" />
<frame name = "center" src = "/html/main_frame.htm" />
<frame name = "right" src = "/html/bottom_frame.htm" />
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
Sr.No Attribute & Description
cols
Specifies how many columns are contained in the frameset and the size of each column. You
can specify the width of each column in one of the four ways −
Absolute values in pixels. For example, to create three vertical frames, use cols = "100, 500, 100".
A percentage of the browser window. For example, to create three vertical frames, use cols =
"10%, 80%, 10%".
1
Using a wildcard symbol. For example, to create three vertical frames, use cols = "10%, *, 10%".
In this case wildcard takes remainder of the window.
As relative widths of the browser window. For example, to create three vertical frames, use cols
= "3*, 2*, 1*". This is an alternative to percentages. You can use relative widths of the browser
window. Here the window is divided into sixths: the first column takes up half of the window, the
second takes one third, and the third takes one sixth.
rows
This attribute works just like the cols attribute and takes the same values, but it is used to specify
2
the rows in the frameset. For example, to create two horizontal frames, use rows = "10%, 90%".
You can specify the height of each row in the same way as explained above for columns.
border
3 This attribute specifies the width of the border of each frame in pixels. For example, border = "5".
A value of zero means no border.
frameborder
This attribute specifies whether a three-dimensional border should be displayed between
4
frames. This attribute takes value either 1 (yes) or 0 (no). For example frameborder = "0" specifies
no border.
framespacing
This attribute specifies the amount of space between frames in a frameset. This can take any
5
integer value. For example framespacing = "10" means there should be 10 pixels spacing
between each frames.
Sr.No Attribute & Description
src
This attribute is used to give the file name that should be loaded in the frame. Its
1
value can be any URL. For example, src = "/html/top_frame.htm" will load an
HTML file available in html directory.
name
This attribute allows you to give a name to a frame. It is used to indicate which
frame a document should be loaded into. This is especially important when you
2
want to create links in one frame that load pages into an another frame, in
which case the second frame needs a name to identify itself as the target of
the link.
frameborder
This attribute specifies whether or not the borders of that frame are shown; it
3
overrides the value given in the frameborder attribute on the <frameset> tag if
one is given, and this can take values either 1 (yes) or 0 (no).
marginwidth
This attribute allows you to specify the width of the space between the left and
4
right of the frame's borders and the frame's content. The value is given in pixels.
For example marginwidth = "10".
marginheight
This attribute allows you to specify the height of the space between the top
5
and bottom of the frame's borders and its contents. The value is given in pixels.
For example marginheight = "10".
FORMS
FORMS
Text Box
Drop-down Menu
Radio Buttons
Checkboxes
Text Area
EXAMPLE: FORM
Reset Button
Submit Button
A form shell has three important parts:
the <FORM> tag, which includes the address of
the script which will process the form
the form elements, like text boxes and radio
buttons
the submit button which triggers the script to send
the entered information to the server
CREATING CHECKBOXES
<B> Color: </B>
<INPUT TYPE="checkbox"
NAME="Color" VALUE="Red">Red
<INPUT TYPE="checkbox"
NAME="Color"
VALUE="Navy">Navy
<INPUT TYPE="checkbox"
NAME="Color"
VALUE="Black">Black
EXAMPLE: CHECKBOXES
To create a drop-down menu, type <SELECT
NAME=“name” SIZE=n MULTIPLE>
Then type <OPTION VALUE= “value”>Label
In this case the SIZE attribute specifies the height
of the menu in lines and MULTIPLE allows users to
select more than one menu option
TABLES
The BORDER=n attribute allows you to add a
border n pixels thick around the table
To make a solid border color, use the
BORDERCOLOR=“color” attribute
To make a shaded colored border, use
BODERCOLORDARK=“color” and
BORDERCOLORLIGHT=“color”
ADDING A BORDER
<TABLE BORDER=10>
<TR>
<TD>One</TD>
<TD>Two</TD>
Here’show it would </TR>
look on the Web: <TR>
<TD>Three</TD>
<TD>Four</TD>
</TR>
</TABLE>
<td>Austria</td>
</head>
</tr>
<body>
<tr>
<td>Island Trading</td>
<h2>HTML Table</h2>
<td>Helen Bennett</td>
<td>UK</td>
<table>
</tr>
<tr>
<tr>
<th>Company</th>
<td>Laughing Bacchus Winecellars</td>
<th>Contact</th>
<td>Yoshi Tannamuri</td>
<th>Country</th>
<td>Canada</td>
</tr>
</tr>
<tr> <tr>
<td>Alfreds Futterkiste</td> <td>Magazzini Alimentari Riuniti</td>
<td>Maria Anders</td> <td>Giovanni Rovelli</td>
<td>Germany</td> <td>Italy</td>
</tr> </tr>
<tr> </table>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td> </body>
<td>Mexico</td> </html>
</tr>
<tr>
When a Web browser displays a table, it often
adds extra space. To eliminate this space use the
WIDTH =n attribute in the <TABLE> and <TD> tags
Keep in mind - a cell cannot be smaller than its
contents, and if you make a table wider than the
browser window, users will not be able to see
parts of it.
CENTERING A TABLE
Itis possible to wrap text around a table.
This technique is often used to keep
images and captions together within an
article.
To wrap text around a table, type <TABLE
ALIGN = LEFT> to align the table to the
left while the text flows to the right.
Create the table using the <TR>, <TD>,
and </TABLE> tags as you normally
would
NESTING TABLES
To change a cell’s color, add the
BGCOLOR=“color” attribute to the <TD> tag
Example:
<TD BGCOLOR=“blue”>
COLUMN GROUPS
You can also create a horizontal section
consisting of one or more rows. This allows you to
format the rows all at once
To create a horizontal section, type <THEAD>,
<TBODY>, or <TFOOT> before the first <TR> tag of
the section
Netscape does not support these tags