Webtechnologies _CIE-356 T_Unit 1 Notes
Webtechnologies _CIE-356 T_Unit 1 Notes
Unit 1 Notes
WebTechnologies(CIE-356T)
HTML Introduction
What is HTML?
Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
Example Explained
• The <body> element defines the document's body, and is a container for all the visible
contents, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.
• The <h1> element defines a large heading
• The <p> element defines a paragraph
An HTML element is defined by a start tag, some content, and an end tag:
The HTML element is everything from the start tag to the end tag:
Web Browsers
The purpose of a web browser (Chrome, Edge, Firefox, Safari) is to read HTML documents
and display them correctly.
A browser does not display the HTML tags, but uses them to determine how to display the
document:
<html>
<head>
<title>Page title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Note: The content inside the <body> section will be displayed in a browser. The content inside the
<title> element will be shown in the browser's title bar or in the page's tab.
HTML History
Since the early days of the World Wide Web, there have been many versions of HTML:
Year Version
HTML Documents
All HTML documents must start with a document type declaration: <!DOCTYPE html>.
The HTML document itself begins with <html> and ends with </html>.
The visible part of the HTML document is between <body> and </body>.
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
The <!DOCTYPE> declaration represents the document type, and helps browsers to display
web pages correctly.
It must only appear once, at the top of the page (before any HTML tags).
<!DOCTYPE html>
HTML Headings
<h1> defines the most important heading. <h6> defines the least important heading:
Example
Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
HTML Links
Example
HTML Images
The source file (src), alternative text (alt), width, and height are provided as attributes:
Example
Have you ever seen a Web page and wondered "Hey! How did they do that?"
Click CTRL + U in an HTML page, or right-click on the page and select "View Page
Source". This will open a new tab containing the HTML source code of the page.
Right-click on an element (or a blank area), and choose "Inspect" to see what elements are
made up of (you will see both the HTML and the CSS). You can also edit the HTML or CSS
on-the-fly in the Elements or Styles panel that opens.
HTML Elements
An HTML element is defined by a start tag, some content, and an end tag.
HTML Elements
The HTML element is everything from the start tag to the end tag:
Note: Some HTML elements have no content (like the <br> element). These elements are called
empty elements. Empty elements do not have an end tag!
HTML elements can be nested (this means that elements can contain other elements).
The following example contains four HTML elements (<html>, <body>, <h1> and <p>):
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Example Explained
The <html> element is the root element and it defines the whole HTML document.
<body>
</body>
Then, inside the <body> element there are two other elements: <h1> and <p>:
Some HTML elements will display correctly, even if you forget the end tag:
Example
<html>
<body>
<p>This is a paragraph
<p>This is a paragraph
</body>
</html>
However, never rely on this! Unexpected results and errors may occur if you forget the
end tag!
The <br> tag defines a line break, and is an empty element without a closing tag:
Example
HTML tags are not case sensitive: <P> means the same as <p>.
The HTML standard does not require lowercase tags, but W3C recommends lowercase in
HTML, and demands lowercase for stricter document types like XHTML.
HTML Attributes
HTML Attributes
The <a> tag defines a hyperlink. The href attribute specifies the URL of the page the link
goes to:
Example
You will learn more about links in our HTML Links chapter.
The <img> tag is used to embed an image in an HTML page. The src attribute specifies the
path to the image to be displayed:
Example
<img src="img_girl.jpg">
There are two ways to specify the URL in the src attribute:
Notes: External images might be under copyright. If you do not get permission to use it, you
may be in violation of copyright laws. In addition, you cannot control external images; it can
suddenly be removed or changed.
2. Relative URL - Links to an image that is hosted within the website. Here, the URL does
not include the domain name. If the URL begins without a slash, it will be relative to the
current page. Example: src="img_girl.jpg". If the URL begins with a slash, it will be relative
to the domain. Example: src="/images/img_girl.jpg".
Tip: It is almost always best to use relative URLs. They will not break if you change domain.
The <img> tag should also contain the width and height attributes, which specify the width
and height of the image (in pixels):
Example
The required alt attribute for the <img> tag specifies an alternate text for an image, if the
image for some reason cannot be displayed. This can be due to a slow connection, or an error
in the src attribute, or if the user uses a screen reader.
Example
Example
See what happens if we try to display an image that does not exist:
The style attribute is used to add styles to an element, such as color, font, size, and more.
Example
You should always include the lang attribute inside the <html> tag, to declare the language of
the Web page. This is meant to assist search engines and browsers.
<!DOCTYPE html>
<html lang="en">
<body>
...
</body>
</html>
Country codes can also be added to the language code in the lang attribute. So, the first two
characters define the language of the HTML page, and the last two characters define the
country.
The following example specifies English as the language and United States as the country:
<!DOCTYPE html>
<html lang="en-US">
<body>
...
</body>
</html>
The title Attribute
The value of the title attribute will be displayed as a tooltip when you mouse over the
element:
Example
The title attribute (and all other attributes) can be written with uppercase or lowercase
like title or TITLE.
The HTML standard does not require quotes around attribute values.
However, W3C recommends quotes in HTML, and demands quotes for stricter document
types like XHTML.
Good:
Bad:
Sometimes you have to use quotes. This example will not display the title attribute correctly,
because it contains a space:
Example
Double quotes around attribute values are the most common in HTML, but single quotes can
also be used.
In some situations, when the attribute value itself contains double quotes, it is necessary to
use single quotes:
Or vice versa:
• The width and height attributes of <img> provide size information for images
• The alt attribute of <img> provides an alternate text for an image
• The style attribute is used to add styles to an element, such as color, font, size, and
more
• The lang attribute of the <html> tag declares the language of the Web page
• The title attribute defines some extra information about an element
HTML Headings
HTML headings are titles or subtitles that you want to display on a webpage.
Example
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
HTML Headings
<h1> defines the most important heading. <h6> defines the least important heading.
Example
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Note: Browsers automatically add some white space (a margin) before and after a heading.
Search engines use the headings to index the structure and content of your web pages.
Users often skim a page by its headings. It is important to use headings to show the document
structure.
<h1> headings should be used for main headings, followed by <h2> headings, then the less
important <h3>, and so on.
Note: Use HTML headings for headings only. Don't use headings to make text BIG or bold.
Bigger Headings
Each HTML heading has a default size. However, you can specify the size for any heading
with the style attribute, using the CSS font-size property:
Example
W3Schools' tag reference contains additional information about these tags and their
attributes.
Tag Description
HTML has several semantic elements that define the different parts of a web page:
There are four different techniques to create multicolumn layouts. Each technique has its pros
and cons:
• CSS framework
• CSS float property
• CSS flexbox
• CSS grid
CSS Frameworks
If you want to create your layout fast, you can use a CSS framework,
like W3.CSS or Bootstrap.
It is common to do entire web layouts using the CSS float property. Float is easy to learn -
you just need to remember how the float and clear properties work. Disadvantages: Floating
elements are tied to the document flow, which may harm the flexibility. Learn more about
float in our CSS Float and Clear chapter.
Use of flexbox ensures that elements behave predictably when the page layout must
accommodate different screen sizes and different display devices.
The CSS Grid Layout Module offers a grid-based layout system, with rows and columns,
making it easier to design web pages without having to use floats and positioning.
HTML Iframes
An inline frame is used to embed another document within the current HTML document.
Syntax
Tip: It is a good practice to always include a title attribute for the <iframe>. This is used by
screen readers to read out what the content of the iframe is.
Use the height and width attributes to specify the size of the iframe.
Example
Or you can add the style attribute and use the CSS height and width properties:
Example
To remove the border, add the style attribute and use the CSS border property:
Example
With CSS, you can also change the size, style and color of the iframe's border:
Example
The target attribute of the link must refer to the name attribute of the iframe:
Example
HTML Links
Links are found in nearly all web pages. Links allow users to click their way from page to
page.
When you move the mouse over a link, the mouse arrow will turn into a little hand.
Note: A link does not have to be text. A link can be an image or any other HTML element!
The HTML <a> tag defines a hyperlink. It has the following syntax:
The most important attribute of the <a> element is the href attribute, which indicates the
link's destination.
The link text is the part that will be visible to the reader.
Clicking on the link text, will send the reader to the specified URL address.
Example
By default, the linked page will be displayed in the current browser window. To change this,
you must specify another target for the link.
• _self - Default. Opens the document in the same window/tab as it was clicked
• _blank - Opens the document in a new window or tab
• _parent - Opens the document in the parent frame
• _top - Opens the document in the full body of the window
Example
Use target="_blank" to open the linked document in a new browser window or tab:
Both examples above are using an absolute URL (a full web address) in the href attribute.
A local link (a link to a page within the same website) is specified with a relative
URL (without the "https://www" part):
Example
<h2>Absolute URLs</h2>
<p><a href="https://www.w3.org/">W3C</a></p>
<p><a href="https://www.google.com/">Google</a></p>
<h2>Relative URLs</h2>
To use an image as a link, just put the <img> tag inside the <a> tag:
Example
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;">
</a>
Link to an Email Address
Use mailto: inside the href attribute to create a link that opens the user's email program (to let
them send a new email):
Example
To use an HTML button as a link, you have to add some JavaScript code.
JavaScript allows you to specify what happens at certain events, such as a click of a button:
Example
Link Titles
The title attribute specifies extra information about an element. The information is most often
shown as a tooltip text when the mouse moves over the element.
Example
Example
Example
Link to a page located in the html folder on the current web site:
Example
Chapter Summary
An HTML link is displayed in a different color depending on whether it has been visited, is
unvisited, or is active.
Example
Here, an unvisited link will be green with no underline. A visited link will be pink with no
underline. An active link will be yellow and underlined. In addition, when mousing over a link
(a:hover) it will become red and underlined:
<style>
a:link {
color: green;
background-color: transparent;
text-decoration: none;
}
a:visited {
color: pink;
background-color: transparent;
text-decoration: none;
}
a:hover {
color: red;
background-color: transparent;
text-decoration: underline;
}
a:active {
color: yellow;
background-color: transparent;
text-decoration: underline;
}
</style>
Link Buttons
This is a link
Example
<style>
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 15px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
}
a:hover, a:active {
background-color: red;
}
</style>
HTML Lists
HTML lists allow web developers to group a set of related items in lists.
Example
• Item
• Item
• Item
• Item
1. First item
2. Second item
3. Third item
4. Fourth item
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
The list items will be marked with bullets (small black circles) by default:
Example
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Ordered HTML List
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
Example
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
HTML Description Lists
The <dl> tag defines the description list, the <dt> tag defines the term (name), and
the <dd> tag describes each term:
Example
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
HTML List Tags
Tag Description
HTML Tables
HTML tables allow web developers to arrange data into rows and columns.
Example
Example
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
Table Cells
Everything between <td> and </td> are the content of the table cell.
Example
<table>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
</table>
Table Rows
Each table row starts with a <tr> and ends with a </tr> tag.
Example
<table>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
<tr>
<td>16</td>
<td>14</td>
<td>10</td>
</tr>
</table>
You can have as many rows as you like in a table; just make sure that the number of cells are
the same in each row.
Note: There are times when a row can have less or more cells than another. You will learn about
that in a later chapter.
Table Headers
Sometimes you want your cells to be table header cells. In those cases use the <th> tag
instead of the <td> tag:
Example
<table>
<tr>
<th>Person 1</th>
<th>Person 2</th>
<th>Person 3</th>
</tr>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
<tr>
<td>16</td>
<td>14</td>
<td>10</td>
</tr>
</table>
By default, the text in <th> elements are bold and centered, but you can change that with
CSS.
HTML Forms
An HTML form is used to collect user input. The user input is most often sent to a server for
processing.
Example
First name:
John
Last name:
Doe
Submit
The HTML <form> element is used to create an HTML form for user input:
<form>
.
form elements
.
</form>
The <form> element is a container for different types of input elements, such as: text fields,
checkboxes, radio buttons, submit buttons, etc.
All the different form elements are covered in this chapter: HTML Form Elements.
An <input> element can be displayed in many ways, depending on the type attribute.
Type Description
All the different input types are covered in this chapter: HTML Input Types.
Text Fields
The <input type="text"> defines a single-line input field for text input.
Example
<form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname">
</form>
First name:
Last name:
Note: The form itself is not visible. Also note that the default width of an input field is 20
characters.
The <label> element is useful for screen-reader users, because the screen-reader will read out
loud the label when the user focuses on the input element.
The <label> element also helps users who have difficulty clicking on very small regions
(such as radio buttons or checkboxes) - because when the user clicks the text within
the <label> element, it toggles the radio button/checkbox.
The for attribute of the <label> tag should be equal to the id attribute of the <input> element
to bind them together.
Radio Buttons
Example
<form>
<input type="radio" id="html" name="fav_language" value="HTML">
<label for="html">HTML</label><br>
<input type="radio" id="css" name="fav_language" value="CSS">
<label for="css">CSS</label><br>
<input type="radio" id="javascript" name="fav_language" value="JavaScript">
<label for="javascript">JavaScript</label>
</form>
HTML
CSS
JavaScript
Checkboxes
Checkboxes let a user select ZERO or MORE options of a limited number of choices.
Example
<form>
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
<label for="vehicle3"> I have a boat</label>
</form>
I have a bike
I have a car
I have a boat
The <input type="submit"> defines a button for submitting the form data to a form-handler.
The form-handler is typically a file on the server with a script for processing input data.
Example
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
First name:
John
Last name:
Doe
Submit
Notice that each input field must have a name attribute to be submitted.
If the name attribute is omitted, the value of the input field will not be sent at all.
Example
This example will not submit the value of the "First name" input field:
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" value="John"><br><br>
<input type="submit" value="Submit">
</form>
HTML Form Attributes
This chapter describes the different attributes for the HTML <form> element.
The action attribute defines the action to be performed when the form is submitted.
Usually, the form data is sent to a file on the server when the user clicks on the submit button.
In the example below, the form data is sent to a file called "action_page.php". This file
contains a server-side script that handles the form data:
Example
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
Tip: If the action attribute is omitted, the action is set to the current page.
The target attribute specifies where to display the response that is received after submitting
the form.
Value Description
The default value is _self which means that the response will open in the current window.
Example
The method attribute specifies the HTTP method to be used when submitting the form data.
The form-data can be sent as URL variables (with method="get") or as HTTP post
transaction (with method="post").
Example
This example uses the GET method when submitting the form data:
Example
This example uses the POST method when submitting the form data:
Notes on GET:
Notes on POST:
• Appends the form data inside the body of the HTTP request (the submitted form data
is not shown in the URL)
• POST has no size limitations, and can be used to send large amounts of data.
• Form submissions with POST cannot be bookmarked
The autocomplete attribute specifies whether a form should have autocomplete on or off.
When autocomplete is on, the browser automatically complete values based on values that the
user has entered before.
Example
When present, it specifies that the form-data (input) should not be validated when submitted.
Example
The HTML <form> element can contain one or more of the following form elements:
• <input>
• <label>
• <select>
• <textarea>
• <button>
• <fieldset>
• <legend>
• <datalist>
• <output>
• <option>
• <optgroup>
The <input> element can be displayed in several ways, depending on the type attribute.
Example
All the different values of the type attribute are covered in the next chapter: HTML Input
Types.
The <label> element is useful for screen-reader users, because the screen-reader will read out
loud the label when the user focus on the input element.
The <label> element also help users who have difficulty clicking on very small regions (such
as radio buttons or checkboxes) - because when the user clicks the text within
the <label> element, it toggles the radio button/checkbox.
The for attribute of the <label> tag should be equal to the id attribute of the <input> element
to bind them together.
Example
Example
Example
Use the multiple attribute to allow the user to select more than one value:
Example
Example
The rows attribute specifies the visible number of lines in a text area.
You can also define the size of the text area by using CSS:
Example
Example
Click Me!
Note: Always specify the type attribute for the button element. Different browsers may use different
default types for the button element.
Example
<form action="/action_page.php">
<fieldset>
<legend>Personalia:</legend>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</fieldset>
</form>
Personalia:First name:
John
Last name:
Doe
Submit
The <datalist> element specifies a list of pre-defined options for an <input> element.
Users will see a drop-down list of the pre-defined options as they input data.
The list attribute of the <input> element, must refer to the id attribute of
the <datalist> element.
Example
<form action="/action_page.php">
<input list="browsers">
<datalist id="browsers">
<option value="Edge">
<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari">
</datalist>
</form>
The <output> element represents the result of a calculation (like one performed by a script).
Example
<form action="/action_page.php"
oninput="x.value=parseInt(a.value)+parseInt(b.value)">
0
<input type="range" id="a" name="a" value="50">
100 +
CSS Introduction
• What is CSS?
• CSS stands for Cascading Style Sheets
• CSS describes how HTML elements are to be displayed on screen, paper, or in other
media
• CSS saves a lot of work. It can control the layout of multiple web pages all at once
• External stylesheets are stored in CSS files
• CSS Demo - One HTML Page - Multiple Styles!
Here we will show one HTML page displayed with four different stylesheets. Click on
the "Stylesheet 1", "Stylesheet 2", "Stylesheet 3", "Stylesheet 4" links below to see the
different styles:
CSS is used to define styles for your web pages, including the design, layout and
variations in display for different devices and screen sizes.
CSS Example
body {
background-color: lightblue;
}
h1 {
color: white;
text-align: center;
}
p{
font-family: verdana;
font-size: 20px;
}
HTML was NEVER intended to contain tags for formatting a web page!
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
When tags like <font>, and color attributes were added to the HTML 3.2 specification, it
started a nightmare for web developers. Development of large websites, where fonts and
color information were added to every single page, became a long and expensive process.
To solve this problem, the World Wide Web Consortium (W3C) created CSS.
With an external stylesheet file, you can change the look of an entire website by changing
just one file!
XML DTD
What is DTD
DTD stands for Document Type Definition. It defines the legal building blocks of an XML
document. It is used to define document structure with a list of legal elements and attributes.
Purpose of DTD
Its main purpose is to define the structure of an XML document. It contains a list of legal
elements and define the structure with the help of them.
Checking Validation
Before proceeding with XML DTD, you must check the validation. An XML document is
called "well-formed" if it contains the correct syntax.
A well-formed and valid XML document is one which have been validated against DTD.
Let's take an example of well-formed and valid XML document. It follows all the rules of
DTD.
employee.xml
. <?xml version="1.0"?>
. <!DOCTYPE employee SYSTEM "employee.dtd">
. <employee>
. <firstname>vimal</firstname>
. <lastname>jaiswal</lastname>
. <email>[email protected]</email>
. </employee>
In the above example, the DOCTYPE declaration refers to an external DTD file. The content
of the file is shown in below paragraph.
employee.dtd
Description of DTD
<!DOCTYPE employee : It defines that the root element of the document is employee.
<!ELEMENT firstname: It defines that the firstname element is #PCDATA typed. (parse-
able data type).
<!ELEMENT lastname: It defines that the lastname element is #PCDATA typed. (parse-
able data type).
<!ELEMENT email: It defines that the email element is #PCDATA typed. (parse-able data
type).
A doctype declaration can also define special strings that can be used in the XML file.
1. An ampersand (&)
2. An entity name
3. A semicolon (;)
author.xml
XML Schema
XML schema is a language which is used for expressing constraint about XML documents.
There are so many schema languages which are used now a days for example Relax- NG and
XSD (XML schema definition).
An XML schema is used to define the structure of an XML document. It is like DTD but
provides more control on XML structure.
Checking Validation
employee.xsd
. <?xml version="1.0"?>
. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
. targetNamespace="http://www.javatpoint.com"
. xmlns="http://www.javatpoint.com"
. elementFormDefault="qualified">
.
. <xs:element name="employee">
. <xs:complexType>
. <xs:sequence>
. <xs:element name="firstname" type="xs:string"/>
. <xs:element name="lastname" type="xs:string"/>
. <xs:element name="email" type="xs:string"/>
. </xs:sequence>
. </xs:complexType>
. </xs:element>
.
. </xs:schema>
Let's see the xml file using XML schema or XSD file.
employee.xml
. <?xml version="1.0"?>
. <employee
. xmlns="http://www.javatpoint.com"
. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
. xsi:schemaLocation="http://www.javatpoint.com employee.xsd">
.
. <firstname>vimal</firstname>
. <lastname>jaiswal</lastname>
. <email>[email protected]</email>
. </employee>
Test it Now
1. simpleType
2. complexType
simpleType
The simpleType allows you to have text-based elements. It contains less attributes, child
elements, and cannot be left empty.
complexType
The complexType allows you to hold multiple attributes and elements. It can contain
additional sub elements and can be left empty.
Attribute type=”beer”
Text Carlsberg
Parsers are used to process XML documents. The parser examines the XML document,
checks for errors, and then validate it against a schema or DTD if it’s a validating parser.
The next step is determined by the parser in use. It may copy the data into a data structure
native to the computer language you’re using on occasion. It may also apply styling to the
data or convert it into a presentation format.
Apart from triggering certain events, the SAX parser does nothing with the data. It is up to
the SAX parser’s user to decide. The SAX events include (among others) as follows:
1. XML Text Nodes
2. XML Element Starts and Ends
3. XML Processing Instructions
4. XML Comments
The properties of SAX Parser are depicted below as follows:
XHTML Introduction
XHTML or EXtensible HyperText Markup Language is a mix of HTML and XML, very
similar to HTML but stricter. It’s like a rulebook for creating web pages that browsers easily
understand. Unlike HTML, you have to be careful and follow the rules exactly. Most
browsers support it. Just think of it as a more precise way to write web code.
History
It was developed by the World Wide Web Consortium (W3C) and helps web developers
transition from HTML to XML. With XHTML, developers can enter the XML world with all
its features while still ensuring backward and future compatibility of the content. The
XHTML family includes three document types; the first is XHTML 1.0, which was
recommended by W3C on January 26, 2000. The second is XHTML 1.1, which was
recommended by W3C on May 31, 2001.
The third is XHTML5, a standard used for developing an XML adaptation of the HTML5
specification. An XHTML document must have an XHTML <!DOCTYPE> declaration.
Elements of XHTML:
XHTML Element Description
rendering in browsers.
When creating an XHTML web page, it is necessary to include a DTD (Document Type
Definition) declaration. There are three types of DTD which are discussed below:
Transitional DTD:
It is supported by the older browsers which do not have inbuilt cascading style sheets
supports. Several attributes are enclosed in the body tag which are not allowed in strict DTD.
Syntax:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
Example: In this example we will see the code for writing an XHTML document with an
example.
• html
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Transitional DTD XHTML</title>
</head>
<body bgcolor="#dae1ed">
<div style="color:#090;font-size:40px;
font-weight:bold;text-align:center;
margin-bottom:-25px;">GeeksforGeeks</div>
<p style="text-align:center;font-size:20px;">
A computer science portal</p>
<p style="text-align:center;font-size:20px;">
Option to choose month:
<select name="month">
<option selected="selected">January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>Augusy</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
</p>
</body>
</html>
Strict DTD:
Strict DTD is used when XHTML page contains only markup language. Strict DTD is used
together with cascading style sheets, because this attribute does not allow CSS property in
body tag.
Syntax:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
Example 2: In this example we will see the code for writing an XHTML document with an
example for strict DTD.
• html
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en">
<head>
<title>Strict DTD XHTML</title>
</head>
<body>
<div style="color:#090;font-size:40px;
font-weight:bold;text-align:center;
margin-bottom:-25px;">GeeksforGeeks</div>
<p style="text-align:center;font-size:20px;">
A computer science portal</p>
<p style="text-align:center;font-size:20px;">
Option to choose month:
<select name="month">
<option selected="selected">January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>Augusy</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
</p>
</body>
</html>
Frameset DTD:
The frameset DTD is used when XHTML page contains frames. This DTD is identical to the
HTML 4.01 Transitional DTD except for the content model of the HTML element.
Syntax:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
HTML XHTML
Example
<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>
The <meta> tag defines metadata about an HTML document. Metadata is data (information)
about data.
<meta> tags always go inside the <head> element, and are typically used to specify character
set, page description, keywords, author of the document, and viewport settings.
Metadata is used by browsers (how to display content or reload page), search engines
(keywords), and other web services.
There is a method to let web designers take control over the viewport (the user's visible area
of a web page), through the <meta> tag (See "Setting The Viewport" example below).
Browser Support
Element
Attributes
Attribute Value Description
Global Attributes
More Examples
Setting the viewport to make your website look good on all devices:
Syntax
This attribute is used to give names to the frame. It differentiate one frame from another. It is
also used to indicate which frame a document should loaded into.
Example
<frame name = "top" src = "C:/Users/dharam/Desktop/attr1.png" />
<frame name = "main" src = "C:/Users/dharam/Desktop/gradient3.png" />
<frame name = "bottom" src = "C:/Users/dharam/Desktop/col_last.png" />
Here we use three frames with names as left center and right.
This attribute in frame tag is basically used to define the source file that should be loaded into
the frame.The value of src can be any url.
Example
<frame name = "left" src = "/html/left.htm" />
In the above example name of frame is left and source file will be loaded from
“/html/left.htm” in frame.
This attribute in frame tag is used to specify width of the spaces in pixels between the border
and contents of left and right frame.
Example
<frame marginwidth="20">
This attribute in frame tag is used to specify height of the spaces in pixels between the border
and contents of top and bottom frame.
Example
<frame marginheight="20">
To control the appearance of scroll bar in frame use scrollbar attribute in frame tag. This is
basically used to control the appearance of scrollbar. The value of this attribute can be yes,
no, auto. Where the value no denotes there will be no appearance of scroll bar.
Example
<frame scrollbar="no">