Web Tech Notes
Web Tech Notes
HTML Lists are used to specify lists of information. There are three different types of
HTML lists:
In the ordered HTML lists, all the list items are marked with numbers by default. It is
known as numbered list also. The ordered list starts with <ol> tag and the list items start
with <li> tag.
example
<ol type="1">
<li>Aries</li>
<li>Bingo</li>
<li>Leo</li>
<li>Oracle</li>
</ol>
Output:
1. Aries
2. Bingo
3. Leo
4. Oracle
In HTML Unordered list, all the list items are marked with bullets. It is also known as
bulleted list also. The Unordered list starts with <ul> tag and list items start with the <li>
tag.
1
example
<ul>
<li>Aries</li>
<li>Bingo</li>
<li>Leo</li>
<li>Oracle</li>
</ul>
Output:
⦁ Aries
⦁ Bingo
⦁ Leo
⦁ Oracle
HTML Description list is also a list style which is supported by HTML and XHTML. It is also known
as definition list where entries are listed like a dictionary or encyclopedia.
The definition list is very appropriate when you want to present glossary, list of terms or other
name-value list.
2
example:
<dl>
<dt>Aries</dt>
<dt>Bingo</dt>
<dt>Leo</dt>
<dt>Oracle</dt>
</dl>
Output:
Aries
Bingo
Leo
Oracle
HTML Table:
HTML table tag is used to display data in tabular form (row * column). There can be
many columns in a row.
We can create a table to display data in tabular form, using <table> element, with the help
of <tr> , <td>, and <th> elements.
3
In Each table, table row is defined by <tr> tag, table header is defined by <th>, and table
data is defined by <td> tags.
HTML tables are used to manage the layout of the page e.g. header section, navigation
bar, body content, footer section etc. But it is recommended to use div tag over table to
manage the layout of the page .
Tag Description
<col> It is used with <colgroup> element to specify column properties for each
column.
example:
<table>
<tr>
<th>First_Name</th>
<th>Last_Name</th>
<th>Marks</th>
4
</tr>
<tr>
<td>Sonoo</td>
<td>Jaiswal</td>
<td>60</td>
</tr>
<tr>
<td>James</td>
<td>William</td>
<td>80</td>
</tr>
<tr>
<td>Swati</td>
<td>Sironi</td>
<td>82</td>
</tr>
<tr>
<td>Chetna</td>
<td>Singh</td>
<td>72</td>
</tr>
</table>
Output:
5
First_Name
Last_Name
Marks
Sonoo
Jaiswal
60
James
William
80
Swati
Sironi
82
Chetna
Singh
72
You can use border attribute of table tag in HTML to specify border. But it is not
recommended now.
example:
6
<table border="1">
<tr>
<th>First_Name</th>
<th>Last_Name</th>
<th>Marks</th>
</tr>
<tr>
<td>Sonoo</td>
<td>Jaiswal</td>
<td>60</td>
</tr>
<tr>
<td>James</td>
<td>William</td>
<td>80</td>
</tr>
<tr>
<td>Swati</td>
<td>Sironi</td>
<td>82</td>
</tr>
<tr>
<td>Chetna</td>
<td>Singh</td>
7
<td>72</td>
</tr>
</table>
Output:
1.It is now recommended to use border property of CSS to specify border in table.
example:
<style>
table, th, td {
</style>
2. You can collapse all the borders in one border by border-collapse property. It will
collapse the border into one.
example:
<style>
table, th, td {
border-collapse: collapse;
</style>
You can specify padding for table header and table data by two ways:
8
⦁ By padding property in CSS
The cellpadding attribute of HTML table tag is obselete now. It is recommended to use
CSS. So let's see the code of CSS.
example:
<style>
table, th, td {
border-collapse: collapse;
th, td {
padding: 10px;
</style>
We can specify the HTML table width using the CSS width property. It can be specify in
pixels or percentage.
We can adjust our table width as per our requirement. Following is the example to display
table with width.
example:
table{
width: 100%;
Example:
<!DOCTYPE html>
<html>
9
<head>
<title>table</title>
<style>
table{
border-collapse: collapse;
width: 100%;
th,td{
padding: 15px;
</style>
</head>
<body>
<table>
<tr>
<th>1 header</th>
<th>1 header</th>
<th>1 header</th>
</tr>
<tr>
<td>1data</td>
<td>1data</td>
10
<td>1data</td>
</tr>
<tr>
<td>2 data</td>
<td>2 data</td>
<td>2 data</td>
</tr>
<tr>
<td>3 data</td>
<td>3 data</td>
<td>3 data</td>
</tr>
</table>
</body>
</html>
If you want to make a cell span more than one column, you can use the colspan attribute.
It will divide one cell/row into multiple columns, and the number of columns depend on
the value of colspan attribute.
CSS code:
<style>
table, th, td {
11
border-collapse: collapse;
th, td {
padding: 5px;
</style>
HTML code:
<table style="width:100%">
<tr>
<th>Name</th>
</tr>
<tr>
<td>Ajeet Maurya</td>
<td>abc</td>
<td>xyz</td>
</tr>
</table>
If you want to make a cell span more than one row, you can use the rowspan attribute.
It will divide a cell into multiple rows. The number of divided rows will depend on
rowspan values.
CSS code:
12
<style>
table, th, td {
border-collapse: collapse;
th, td {
padding: 10px;
</style>
HTML code:
<table>
<tr><th>Name</th><td>Ajeet Maurya</td></tr>
<tr><td>xyz</td></tr>
</table>
HTML caption is diplayed above the table. It must be used after table tag only.
example:
<table>
<caption>Student Records</caption>
<tr>
<th>First_Name</th>
<th>Last_Name</th>
<th>Marks</th>
13
</tr>
<tr>
<td>Vimal</td>
<td>Jaiswal</td>
<td>70</td>
</tr>
<tr>
<td>Mike</td>
<td>Warn</td>
<td>60</td>
</tr>
<tr>
<td>Shane</td>
<td>Warn</td>
<td>42</td>
</tr>
<tr>
<td>Jai</td>
<td>Malhotra</td>
<td>62</td>
</tr>
</table>
CSS code:
14
<style>
table, th, td {
border-collapse: collapse;
th, td {
padding: 10px;
table#alter tr:nth-child(even) {
background-color: #eee;
table#alter tr:nth-child(odd) {
background-color: #fff;
table#alter th {
color: white;
background-color: gray;
</style>
HTML Image:
HTML img tag is used to display image on the web page. HTML img tag is an empty tag
that contains attributes only, closing tags are not used in HTML image element.
15
example of HTML image.
1) src
It is a necessary attribute that describes the source or path of the image. It instructs the
browser where to look for the image on the server.
2) alt
The alt attribute defines an alternate text for the image, if it can't be displayed. The value
of the alt attribute describe the image in words.
3) width
It is an optional attribute which is used to specify the width to display the image. It is not
recommended now. You should apply CSS in place of width attribute.
4) height
It h3 the height of the image. The HTML height attribute also supports iframe, image and
object elements. It is not recommended now. You should apply CSS in place of height
attribute.
If we want to display image according to our requirement, then we can set height and
width attributes of image. Both of these attributes are optional. If you do not specify these
attributes, the browser will shown an image width its original size. You can set the value
of height and width attribute in pixels or in percentage ranging from 1 to 100.
Example:
5) hspace attribute:
The hspace attribute is used to inserts an equal space on the left and right side of an
image.
6) vspace attribute:
16
The vspace attribute is used to inserts an equal space on the top and bottom of an image.
Example:
<!DOCTYPE>
<html>
<body>
</body>
</html>
7) border attribute:
If you want to create a frame around an image then it is possible using border attribute of
<img> tag. By default, no border appears around an image unless the image is a link. In
order to include border of specific width, we assign the border attribute to some numeric
value in the <img> tag.
Example:
<!DOCTYPE>
<html>
<body>
</body>
</html>
FRAMES:
Frames allow to split the browser window into the multiple rectangular areas. Each area
has its own html webpage, which functions independently.
A frameset is a collection of frames that spans the wntire browser. It instructs the
17
browser on how to devide the browser window into frames and which web page should
be loaded in each frame.
Tag Description
defined.
frame.
FORMS:
Forms are used to input the values. These values are send to the server for processing.
Forms use input elements such as text fields, check boxes, radio buttons, lists, submit
buttons etc.to enter the data into it.
Tag Description
HTML Form:
An HTML form is a section of a document which contains controls such as text fields,
password fields, checkboxes, radio buttons, submit button, menus etc.
18
An HTML form facilitates the user to enter data that is to be sent to the server for
processing such as name, email address, password, phone number, etc. .
HTML forms are required if you want to collect some data from of the site visitor.
For example: If a user want to purchase some items on internet, he/she must fill the form
such as shipping address and credit/debit card details so that item can be sent to the given
address.
</form>
The HTML <input> element is fundamental form element. It is used to create form fields,
to take input from user. We can apply different input filed to gather different information
form user. Following is the example to show the simple text input.
Example:
<body>
<form>
</form>
</body>
The type="text" attribute of input tag creates textfield control also known as single line
textfield control. The name attribute is optional, but it is required for the server side
component such as JSP, ASP, PHP etc.
<form>
19
Last Name: <input type="text" name="lastname"/> <br/>
</form>
The <textarea> tag in HTML is used to insert multiple-line text in a form. The size of
<textarea> can be specify either using "rows" or "cols" attribute or by CSS.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Form in HTML</title>
</head>
<body>
<form>
</form>
</body>
</html>
If you click on the label tag, it will focus on the text control. To do so, you need to have
for attribute in label tag that must be same as id attribute of input tag.
Example:
<form>
20
<label for="firstname">First Name: </label> <br/>
</form>
Example:
<form>
</form>
The email field in new in HTML 5. It validates the text for correct email address. You
must use @ and . in this field.
Example:
<form>
</form>
The radio button is used to select one option from multiple options. It is used for selection
of gender, quiz questions etc.
If you use one name for all the radio buttons, only one radio button can be selected at a
time.
21
Using radio buttons for multiple options, you can only choose a single option at a time.
Example:
<form>
</form>
Checkbox Control:
The checkbox control is used to check multiple options from given checkboxes.
<form>
Hobby:<br>
<label for="hockey">Hockey</label>
</form>
HTML <input type="submit"> are used to add a submit button on web page. When user
clicks on submit button, then form get submit to the server.
Syntax:
22
The value attribute can be anything which we write on button on web page.
Example:
<form>
</form>
The <fieldset> element in HTML is used to group the related information of a form. This
element is used with <legend> element which provide caption for the grouped elements.
Example:
<form>
<fieldset>
<legend>User Information:</legend>
</fieldset>
lt;/form>
23
XML:
XML (eXtensible Markup Language) is a markup language that defines rules for
encoding documents in a format that is both human-readable and machine-readable. It is
widely used to structure, store, and transport data, especially in situations where data
needs to be shared across different systems or platforms.
Characteristics of XML:
Self-descriptive: XML documents contain data and describe the structure of that data
using custom tags.
Extensible: You can define your own tags. There is no fixed set of predefined tags
(unlike HTML, which has predefined tags like <h1>, <p>, etc.).
Supports Unicode: XML supports character encoding schemes like UTF-8 and UTF-16,
making it compatible with a wide range of languages and symbols.
⦁ Root Element: The root element encloses all other elements in the document. An
XML document must have exactly one root element.
⦁ Elements: Elements represent the data in the XML document. They are enclosed
by start (<element>) and end (</element>) tags.
24
about an element.
⦁ Text: Data that is enclosed within an element is considered the text content of that
element.
⦁ Comments: Comments are written inside <!-- --> tags and are not part of the data.
⦁ CDATA: Used to escape text that might otherwise be treated as XML code.
<![CDATA[<html><body></body></html>]]>
<library>
<book id="1">
<author>John Doe</author>
<year>2024</year>
<genre>Programming</genre>
</book>
<book id="2">
<title>Advanced XML</title>
<author>Jane Smith</author>
<year>2025</year>
<genre>Technology</genre>
</book>
25
</library>
Root element: <library> is the root element, and it contains all other elements.
Child elements: <book> is a child element of <library>. Each <book> element contains
other child elements like <title>, <author>, <year>, and <genre>.
Attributes: The id attribute in the <book> element provides additional information about
each book.
Advantages of XML:
⦁ Supports Complex Data Structures: With its hierarchical nature, XML can
represent complex, nested data structures.
Disadvantages of XML:
⦁ Verbose: XML files can become quite large and complex because each data
element needs to be wrapped in tags.
⦁ No Built-In Data Types: XML itself does not define data types for elements,
though this can be handled with XML Schema (XSD).
Uses of XML:
⦁ Web Services: XML is commonly used in web services (such as SOAP) for
exchanging data between clients and servers.
26
between different applications or systems.
A Document Type Definition (DTD) is a set of rules that define the structure and the legal
elements and attributes of an XML document. DTDs specify what elements are allowed
in the document, the order of those elements, and the attributes that can be assigned to the
elements.
Internal DTD: The DTD is defined directly within the XML document itself.
External DTD: The DTD is defined in a separate file and referenced by the XML
document.
Elements of a DTD:
Example:
This defines a book element that must contain title, author, and year elements in that
order.
2. Attribute Declaration: Defines attributes that can be associated with elements, along
with constraints (like data type or whether the attribute is required).
Example:
This indicates that the book element must have an id attribute of type ID and that it is
required.
3. Entity Declaration: Allows you to define shortcuts for commonly used content (like
special characters or reusable text).
27
<!NOTATION pdf SYSTEM "application/pdf">
EXAMPLE:
<?xml version="1.0"?>
<!DOCTYPE library [
]>
<library>
<book>
<title>XML Fundamentals</title>
<author>John Doe</author>
<year>2024</year>
</book>
<book>
<title>Advanced XML</title>
<author>Jane Smith</author>
<year>2025</year>
</book>
</library>
28
structure, promoting consistency.
Limitations of DTD:
⦁ Limited Data Type Support: DTDs only support a small set of data types and
lack full data validation features compared to XML Schema.
⦁ No Namespace Support: DTDs don't support XML namespaces, which can cause
conflicts in documents that use multiple vocabularies.
XML Schema Definition (XSD) is a language used for describing the structure, content,
and data types of XML documents. It defines the rules for what elements and attributes
are allowed, their data types, relationships between elements, and other constraints,
providing a more powerful way of validating XML documents than DTD (Document
Type Definition).
⦁ Data Types: Unlike DTD, which only supports basic types (like text or numbers),
XSD provides a rich set of data types (e.g., string, integer, date, boolean).
⦁ Better Validation: XSD offers more precise control over data validation,
allowing for constraints like maximum length, ranges, and pattern matching.
29
5. Data Types: Specifies the type of data (e.g., string, integer, date).
30