Web Programming Notes
Web Programming Notes
i. Formatting Text 04 - 05
i. Tables 13 - 19
ii. Frames 20 - 22
v. HTML Forms 42 - 45
HTML, which stands for HyperText Markup Language, is the predominant markup languagefor web
pages. HTML is the basic building-blocks of webpages.
HTML is written in the form of HTML elements consisting of tags, enclosed in angle brackets(like
<html>), within the web page content. HTML tags normally come in pairs like <h1> and </h1>. The
first tag in a pair is the start tag, the second tag is the end tag (they are also calledopening tags and
closing tags). In between these tags web designers can add text, tables, images, etc.
The purpose of a web browser is to read HTML documents and compose them into visual or
audible web pages. The browser does not display the HTML tags, but uses the tags to interpret the
content of the page.
HTML elements form the building blocks of all websites. HTML allows images and objects to be
embedded and can be used to create interactive forms. It provides a means to create structured
documents by denoting structural semantics for text such as headings, paragraphs, lists, links,
quotes and other items. It can embed scripts in languages such as JavaScript which affect the
behavior of HTML webpages.
What is HTML?
HTML Tags
The purpose of a web browser (like Internet Explorer or Firefox) is to read HTML documents and
display them as web pages. The browser does not display the HTML tags, but uses the tags to
interpret the content of the page:
Formatting Text-Forms & Formulating Elements –
HTML uses tags like <b> and <i> for formatting output, like bold or italic text. These HTML tags are
called formatting tags
Often <strong> renders as <b>, and <em> renders as <i>.
<strong> or <em> means that you want the text to be rendered in a way that the user understands
as "important". Today, all major browsers render strong as bold and em as italics. However, if a
browser one day wants to make a text highlighted with the strong feature, it might be cursive for
example and not bold!
Tag Description
<dfn> Defines a definition term
<code> Defines computer code text
<samp> Defines sample computer code
<kbd> Defines keyboard text
<var> Defines a variable part of a text
<cite> Defines a citation
<pre> Defines preformatted text
Tag Description
<abbr> Defines an abbreviation
<acronym> Defines an acronym
<address> Defines contact information for the author/owner of a document
<bdo> Defines the text direction
<blockquote> Defines a long quotation
<q> Defines a short quotation
<cite> Defines a citation
<dfn> Defines a definition term
Formatting Forms-
A form can contain input elements like text fields, checkboxes, radio-buttons, submit buttons and
more. A form can also contain select lists, textarea, fieldset, legend, and label elements.
<form>
.
input elements
.
</form>
The most important form element is the input element. The input element is used to select user
information.
An input element can vary in many ways, depending on the type attribute. An input element can
be of type text field, checkbox, password, radio button, submit button, and more.
Text Fields
<input type="text" /> defines a one-line input field that a user can enter text into:
<form>
First name: <input type="text" name="firstname" /><br /> Last name: <input
type="text" name="lastname" />
</form>
First name:
Last name:
Password Field
<form>
Password: <input type="password" name="pwd" />
</form>
Password:
Radio Buttons
<input type="radio" /> defines a radio button. Radio buttons let a user select ONLY ONE one of a
limited number of choices:
<form>
<input type="radio" name="sex" value="male" /> Male<br />
<input type="radio" name="sex" value="female" /> Female
</form>
Male
Female
Checkboxes
<input type="checkbox" /> defines a checkbox. Checkboxes let a user select ONE
or MORE options of a limited number of choices.
<form>
<input type="checkbox" name="vehicle" value="Bike" /> I have a
bike<br />
<input type="checkbox" name="vehicle" value="Car" /> I have a
car
</form>
I have a bike
I have a car
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:
Username: submit
If you type some characters in the text field above, and click the "Submit" button, the browser
will send your input to a page called "html_form_action.asp". The page will show you the
received input
HTML Elements
An HTML element is everything from the start tag to the end tag:
Start tag * Element content End tag *
<p> This is a paragraph </p>
<a href="default.htm" > This is a link </a>
<br />
* The start tag is often called the opening tag. The end tag is often called the closing
tag.
Tip: You will learn about attributes in the next chapter of this tutorial.
Most HTML elements can be nested (can contain other HTML elements). HTML
<html>
<body>
<p>This is my first paragraph.</p>
</body>
</html>
<body>
<p>This is my first paragraph.</p>
</body>
The <body> element defines the body of the HTML document. The
element has a start tag <body> and an end tag </body>. The element
content is another HTML element (a p element).
<html>
<body>
<p>This is my first paragraph.</p>
</body>
</html>
TABLES:
A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the
<td> tag). td stands for "table data," and holds the content of a data cell. A <td> tag can contain
text, links, images, lists, forms, other tables, etc.
Using tables to divide the page into different sections is an extremely powerful tool.
Almost all major sites on the web are using invisible tables to layout the pages.
The most important layout aspects that can be done with tables are:
Tag Description
<table> Defines a table
<th> Defines a table header
<tr> Defines a table row
<td> Defines a table cell
<caption> Defines a table caption
<colgroup> Defines a group of columns in a table, for formatting
<col /> Defines attribute values for one or more columns in a table
<thead> Groups the header content in a table
<tbody> Groups the body content in a table
<tfoot> Groups the footer content in a table
A simple HTML table consists of the table element and one or more tr, th, and td
elements.
The tr element defines a table row, the th element defines a table header, and the td
element defines a table cell.
A more complex HTML table may also include caption, col, colgroup, thead, tfoot, and tbody
elements.
The <th> tag defines a header cell in an HTML table. An HTML table has two kinds of cells:
• Header cells - contains header information (created with the th element)
• Standard cells - contains data (created with the td element) The text in a th element is bold
and centered.
The text in a td element is regular and left-aligned.
The <td> tag defines a standard cell in an HTML table. An HTML table has two kinds of cells:
• Header cells - contains header information (created with the th element)
• Standard cells - contains data (created with the td element) The text in a th element is bold
and centered.
The text in a td element is regular and left-aligned.
The <colgroup> tag is useful for applying styles to entire columns, instead of repeating the styles
for each cell, for each row.
The <col> tag defines attribute values for one or more columns in a table.
The <col> tag is useful for applying styles to entire columns, instead of repeating the styles for
each cell, for each row.
The <col> tag can only be used inside a table or a colgroup element.
The <thead> tag is used to group the header content in an HTML table.
The thead element should be used in conjunction with the tbody and tfoot elements.
The tbody element is used to group the body content in an HTML table and the tfoot element is
used to group the footer content in an HTML table.
Note: <tfoot> must appear before <tbody> within a table, so that a browser can render the foot
before receiving all the rows of data.
Notice that these elements will not affect the layout of the table by default. However, you can use
CSS to let these elements affect the table's layout.
The <tbody> tag is used to group the body content in an HTML table.
The tbody element should be used in conjunction with the thead and tfoot elements.
The thead element is used to group the header content in an HTML table and the tfoot element is
used to group the footer content in an HTML table.
Note: <tfoot> must appear before <tbody> within a table, so that a browser can render the foot
before receiving all the rows of data.
Notice that these elements will not affect the layout of the table by default. However, you can use
CSS to let these elements affect the table's layout.
The <tfoot> tag is used to group the footer content in an HTML table.
The tfoot element should be used in conjunction with the thead and tbody elements.
The thead element is used to group the header content in an HTML table and the tbody element
is used to group the body content in an HTML table.
Note: <tfoot> must appear before <tbody> within a table, so that a browser can render the foot
before receiving all the rows of data.
Notice that these elements will not affect the layout of the table by default. However, you can use
CSS to let these elements affect the table's layout.
Table Example
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
If you do not specify a border attribute, the table will be displayed without borders. Sometimes
this can be useful, but most of the time, we want the borders to show.
<table border="1">
<tr>
<td>Row 1, cell 1</td>
<td>Row 1, cell 2</td>
</tr>
</table>
All major browsers will display the text in the <th> element as bold and centered.
<table border="1">
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Header 1 Header 2
row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2
HTML Frames:
A file that specifies how the screen is divided into frames is called a frameset.
• make the normal HTML documents that should be loaded into each of these frames.
When a frameset page is loaded, the browser automatically loads each of the pages associated
with the frames.
With frames, you can display more than one HTML document in the same browser window. Each
HTML document is called a frame, and each frame is independent of the others.
The frameset element holds one or more frame elements. Each frame element can hold a
separate document.
The frameset element states HOW MANY columns or rows there will be in the frameset, and
HOW MUCH percentage/pixels of space will occupy each of them.
The <frame> tag defines one particular window (frame) within a frameset. In the example below
we have a frameset with two columns.
The first column is set to 25% of the width of the browser window. The second column is set to
75% of the width of the browser window. The document
"frame_a.htm" is put into the first column, and the document "frame_b.htm" is put
into the second column:
Note: Add the <noframes> tag for browsers that do not support frames.
Important: You cannot use the <body></body> tags together with the
<frameset></frameset> tags! However, if you add a <noframes> tag containing some text for
browsers that do not support frames, you will have to enclose the text in <body></body> tags!
See how it is done in the first example below.
Tag Description
<frameset> Defines a set of frames
<frame /> Defines a sub window (a frame)
<noframes> Defines a noframe section for browsers that do not handle frames
The frameset element holds one or more frame elements. Each frame element can hold a
separate document.
The frameset element states HOW MANY columns or rows there will be in the frameset,
and HOW MUCH percentage/pixels of space will occupy each of them.
The <frame> tag defines one particular window (frame) within a frameset.
Each frame in a frameset can have different attributes, such as border, scrolling, the ability
to resize, etc.
The noframes element can contain all the elements that you can find inside the body
element of a normal HTML page.
The noframes element is most used to link to a non-frameset version of the web site or to
display a message to users that frames are required.