Yash Pratap HTML
Yash Pratap HTML
on
“INTRODUCTION TO HTML,CSS - XML”
SUBMITTED IN PARTIAL FULFILMENT OF THE REQUIREMENT FOR THE
AWARD OF THE DEGREE
Of
Bachelor Of Computer
Application
(B.C.A. 1stsem )
( Batch : 2024 – 2027 )
Submitted By Submitted to
Yash Partap Singh Mr Ajay Kumar
2523361050108 (Head,Dept.of C.S,G.C.M.T)
CERTIFICATE
THIS IS TO CERTIFY THAT YASH PARTAP SINGH BEARING ROLL NUMBER
2523361050108 BACHELOR OF COMPUTER SCIENCE HAVE WORKED
FOR THE PREPARATION OF THE PRACTICAL FILE ENTITLED;
“INTRODUCTION TO HTML, CSS - XML”.
Words are always in short when we wish to show our gratitude. While
presenting this report we wish to thank all those who took special
pain during its preparation.
We shall always remain thankful to all our faculty members for their
kind support. We are greatly indebted to our parents and friends for
their love and affection-their wishes have been the source of
encouragement throughout our study.
Roll No 2523361050108
INDEX
1. BASICS OF INTERNET AND WEB 1-9
2. DHTML 10-11
4. CSS 31-40
5. XML 41-49
1
Computers that we use every day are called clients because they are indirectly connected to
the Internet through an internet service provider. When you open a webpage on your
computer, you connect to the webpage, and then you can access it. Computers break the
information into smaller pieces called packets, which are reassembled in their original order.
The below are the steps for how the message is transferred.
Finally, these small pieces- packets reach Computer2 and are reassembled at their IP
address.
The Internet works in a more complex manner than these above-given steps, but this might
give a basic idea of how the internet works.
Advantages of Internet
Internet technology has numerous advantages. You can connect with anyone in this world
without facing any errors. The internet has brought the world close to each other. Have a look
at some essential benefits of internet.
Source of Information
Source of Entertainment
Keep Informed
Online Shopping
Communication
Social Networking
Learning
Earn Money from the Internet
Online Banking
Accessibility
Disadvantages of Internet
The internet has many conveniences, but excessive usage of the internet can affect you in a
variety of ways. There are a lot of uses and limitations of the internet. So, let's explore
the drawbacks of the internet.
A Waste of time
Not Safe Place for Children
Privacy Exposure
Money Frauds
Virus/Malware
Online Threatening or Harassment
Cyberbullying
Wrong Information
Health Issue
3
TCP/IP
TCP/IP is a stream protocol. This means that a connection is negotiated between a client and
a server. Any data transmitted between these two endpoints is guaranteed to arrive, thus it is a
so-called lossless protocol. Since the TCP protocol (as it is also referred to in short form) can
only connect two endpoints, it is also called a peer-to-peer protocol.
HTTP
HTTP is the protocol used to transmit all data present on the World Wide Web. This includes
text, multimedia and graphics. It is the protocol used to transmit HTML, the language that
makes all the fancy decorations in your browser. It works upon TCP/IP.
FTP
FTP is the protocol used to transmit files between computers connected to each other by a
TCP/IP network, such as the Internet.
What is an IP Address ?
An IP address is a unique address that identifies a device on the internet or a local network.
IP stands for "Internet Protocol," which is the set of rules governing the format of data sent
via the internet or local network.
In essence, IP addresses are the identifier that allows information to be sent between devices
on a network: they contain location information and make devices accessible for
communication. The internet needs a way to differentiate between different computers,
routers, and websites. IP addresses provide a way of doing so and form an essential part of
how the internet works.
World Wide Web, which is also known as a Web, is a collection of websites or web pages
stored in web servers and connected to local computers through the internet. These websites
contain text pages, digital images, audios, videos, etc. Users can access the content of these
sites from any part of the world over the internet using their devices such as computers,
4
laptops, cell phones, etc. The WWW, along with internet, enables the retrieval and display of
text and media to your device.
What is a Website ?
A collection of web pages and media over the internet is called a website. The website can be
published on at least one web server and can be identified by a common domain name, for
example - google.com, youtube.com.
Static Website
Dynamic Website
Static website
Static website is the basic type of website that is easy to create. You don't need the
knowledge of web programming and database design to create a static website. Its web pages
are coded in HTML.
SERVER CLIENT/BROWSER
Dynamic website
Dynamic website is a collection of dynamic web pages whose content changes dynamically.
It accesses content from a database or Content Management System (CMS). Therefore, when
you alter or update the content of the database, the content of the website is also altered or
updated.
Dynamic website uses client-side scripting or server-side scripting, or both to generate
dynamic content.
5
Webpage
A web page is a single hypertext document available on World Wide Web (WWW). It is
composed of HTML elements and displayed on the user's browser such as Chrome , Mozilla,
Firefox etc. It is also referred to as "Page."
Home page
The homepage or home page is the name of the main page of a website where visitors can
find hyperlinks to other pages on the site.
SMTP
SMTP stands for Simple Mail Transfer Protocol.
SMTP is a set of communication guidelines that allow software to transmit an electronic
mail over the internet is called Simple Mail Transfer Protocol.
It is a program used for sending messages to other computer users based on e-mail
addresses.
It provides a mail exchange between users on the same or different computers, and it also
supports:
It can send a single message to one or more recipients.
Sending message can include text, voice, video or graphics.
It can also send the messages on networks outside the internet.
Simple Network Management Protocol (SNMP)
SNMP is an application layer protocol that uses UDP port number 161/162.SNMP is used to
monitor the network, detect network faults, and sometimes even used to configure remote
devices.
SNMP components :
There are 3 components of SNMP:
SNMP Manager
It is a centralized system used to monitor network. It is also known as Network Management
Station (NMS)
6
SNMP agent
It is a software management software module installed on a managed device. Managed
devices can be network devices like PC, routers, switches, servers, etc.
What is VBScript ?
7
VBScript (Visual Basic Script) is developed by Microsoft with the intention of developing
dynamic web pages. It is client-side scripting language like JavaScript. VBScript is a light
version of Microsoft Visual Basic. The syntax of VBScript is very similar to that of Visual
Basic. If you want your webpage to be more lively and interactive, then you can incorporate
VBScript in your code.
VBScript is just a scripting language. So, it cannot run its code on its own. It needs a bigger
programming language to host it.
ActiveX controls are component program objects that Microsoft developed to enable
applications to perform specific functions, such as displaying a calendar or playing a video.
An ActiveX control is a small program that other applications can reuse to enable the same
functionality, without the extra development work.
Plugins are software additions that allow for the customization of computer programs, apps,
and web browsers -- as well as the customization of the content offered by websites. While
plugins continue to be used as add-ons to customize programs and apps, their use in web
browsers has decreased somewhat, in favor of using browser extensions instead.
What is an API ?
APIs are mechanisms that enable two software components to communicate with each other
using a set of definitions and protocols. For example, the weather bureau’s software system
contains daily weather data. The weather app on your phone “talks” to this system via APIs
and shows you daily weather updates on your phone.
8
Web browser
Database
Query Results
What is ODBC?
Open Database Connectivity (ODBC) is an open standard Application Programming
Interface (API) for accessing a database. In 1992, Microsoft partners with Simba to build the
world’s first ODBC driver; SIMBA.DLL, and standards-based data access was born. By
using ODBC statements in a program, you can access files in a number of different common
databases. In addition to the ODBC software, a separate module or driver is needed for each
database to be accessed.
9
1.
10
2. DHTML
DHTML stands for Dynamic Hypertext Markup language i.e., Dynamic HTML.
Dynamic HTML is not a markup or programming language but it is a term that combines
the features of various web development technologies for creating the web pages dynamic
and interactive.
The DHTML application was introduced by Microsoft with the release of the 4 th version
of IE (Internet Explorer) in 1997.
HTML 4.0
CSS
JavaScript
DOM.
HTML 4.0
CSS
CSS stands for Cascading Style Sheet, which allows the web users or developers for
controlling the style and layout of the HTML elements on the web pages.
JavaScript
DOM
DOM is the document object model. It is a w3c standard, which is a standard interface of
programming for HTML. It is mainly used for defining the objects and properties of all
elements in HTML.
11
Uses of DHTML
It is used for designing the animated and interactive web pages that are developed in real-
time.
DHTML helps users by animating the text and images in their documents.
It allows the authors for adding the effects on their pages.
It also allows the page authors for including the drop-down menus or rollover buttons.
This term is also used to create various browser-based action games.
It is also used to add the ticker on various websites, which needs to refresh their content
automatically.
Features of DHTML
Its simplest and main feature is that we can create the web page dynamically.
Dynamic Style is a feature, that allows the users to alter the font, size, color, and content
of a web page.
It provides the facility for using the events, methods, and properties. And, also provides
the feature of code reusability.
It also provides the feature in browsers for data binding.
Using DHTML, users can easily create dynamic fonts for their web sites or web pages.
With the help of DHTML, users can easily change the tags and their properties.
The web page functionality is enhanced because the DHTML uses low-bandwidth effect.
12
3. INTRODUCTION TO HTML
HTML – OVERVIEW
HTML stands for Hypertext Markup Language, and it is the most widely used language to
write Web Pages.
Hypertext refers to the way in which Web pages (HTML documents) are linked together.
Thus, the link available on a webpage is called Hypertext
As its name suggests, HTML is a Markup Language which means you use HTML to
simply "mark-up" a text document with tags that tell a Web browser how to structure it to
display.
Originally, HTML was developed with the intent of defining the structure of documents like
headings, paragraphs, lists, and so forth to facilitate the sharing of scientific information
between researchers. Now, HTML is being widely used to format web pages with the help of
different tags available in HTML language.
Now, HTML is being widely used to format web pages with the help of different tags
available in HTML language.
<!DOCTYPE html>
<html>
<head>
<title>This is document title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>Document content goes here.....</p>
</body>
</html>
Either you can use Try it option available at the top right corner of the code box to check the
result of this HTML code, or let's save it in an HTML file test.htm using your favorite text
13
editor. Finally open it using a web browser like Internet Explorer or Google Chrome, or
Firefox etc. It must show the following output:
HTML Tags
As told earlier, HTML is a markup language and makes use of various tags to format the
content. These tags are enclosed within angle braces <Tag Name>. Except few tags, most of
the tags have their corresponding closing tags. For example, <html> has its closing
tag</html> and <body> tag has its closing tag </body> tag etc.
Tag Description
<!DOCTYPE...> This tag defines the document type and HTML version.
The <title> tag is used inside the <head> tag to mention the
<title> document title.
14
To learn HTML, you will need to study various tags and understand how they behave, while
formatting a textual document. Learning HTML is simple as users have to learn the usage of
different tags in order to format the text or images to make a beautiful webpage.
World Wide Web Consortium (W3C) recommends to use lowercase tags starting from
HTML 4.
We will study all the header and body tags in subsequent chapters, but for now let's see what
is document declaration tag.
The <!DOCTYPE> declaration tag is used by the web browser to understand the version of
the HTML used in the document. Current version of HTML is 5 and it makes use of the
following declaration:
<!DOCTYPE html>
There are many other declaration types which can be used in HTML document depending on
what version of HTML is being used.
15
Heading Tags
Any document starts with a heading. You can use different sizes for your headings. HTML
also has six levels of headings, which use the elements <h1>, <h2>, <h3>, <h4>, <h5>, and
<h6>. While displaying any heading, browser adds one line before and one line after that
heading.
Example :
<!DOCTYPE html>
<html>
<head>
<title>Heading Example</title>
</head>
<body>
</body> </html>
Paragraph Tag
The <p> tag offers a way to structure your text into different paragraphs. Each paragraph of
text should go in between an opening <p> and a closing </p> tag as shown below in the
example:
Example:
<!DOCTYPE html>
<html>
<head>
<title>Paragraph Example</title>
</head>
<body>
<p>Here is a first paragraph of text.</p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
</body>
</html>
This will produce the following result:
Whenever you use the <br /> element, anything following it starts from the next line. This
tag is an example of an empty element, where you do not need opening and closing tags, as
there is nothing to go in between them.
The <br /> tag has a space between the characters br and the forward slash. If you omit this
space, older browsers will have trouble rendering the line break, while if you miss the
forward slash character and just use <br> it is not valid in XHTML.
Example :
<!DOCTYPE html>
<html>
<head>
<title>Line Break Example</title>
</head>
<body>
<p>Hello<br />
You delivered your assignment on time.<br />
Thanks<br />
Mr rajput</p>
</body>
</html>
Hello
You delivered your assignment on time.
Thanks Mr Rajput
Centering Content
You can use <center> tag to put any content in the center of the page or any table
cell.
Example :
<!DOCTYPE html>
<html>
18
<head>
<title>Centring Content Example</title>
</head>
<body>
<p>This text is not in the center.</p>
<center>
<p>This text is in the center.</p>
</center>
</body>
</html>
This will produce the following result:
Horizontal Lines
Horizontal lines are used to visually break-up sections of a document. The <hr> tag creates a
line from the current position in the document to the right margin and breaks the line
accordingly.
For example, you may want to give a line between two paragraphs as in the given example
below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Horizontal Line Example</title>
</head>
<body>
<p>This is paragraph one and should be on top</p>
<hr />
<p>This is paragraph two and should be at bottom</p>
</body>
</html>
This will produce the following result:
19
Again <hr /> tag is an example of the empty element, where you do not need opening and
closing tags, as there is nothing to go in between them.
The <hr /> element has a space between the characters hr and the forward slash. If you omit
this space, older browsers will have trouble rendering the horizontal line, while if you miss
the forward slash character and just use <hr> it is not valid in XHTML
Preserve Formatting
Sometimes, you want your text to follow the exact format of how it is written in the HTML
document. In these cases, you can use the preformatted tag <pre>.
Any text between the opening <pre> tag and the closing </pre> tag will preserve the
formatting of the source document.
Example
<!DOCTYPE html>
<html>
<head>
<title>Preserve Formatting Example</title>
</head>
<body>
<pre>
function testFunction( strText ){
alert (strText)
}
</pre>
</body>
</html>
This will produce the following result:
Try using the same code without keeping it inside <pre>...</pre> tags
20
Nonbreaking Spaces
Suppose you want to use the phrase "12 Angry Men." Here, you would not want a browser to
split the "12, Angry" and "Men" across two lines:
In cases, where you do not want the client browser to break text, you should use a
nonbreaking space entity instead of a normal space. For example, when coding the
"12 Angry Men" in a paragraph, you should use something similar to the following code:
Example :
<!DOCTYPE html>
<html>
<head>
<title>Nonbreaking Spaces Example</title>
</head>
<body>
<p>An example of this technique appears in the movie "12 Angry Men."</p>
</body>
</html>
HTML – ELEMENTS
An HTML element is defined by a starting tag. If the element contains other content, it ends
with a closing tag, where the element name is preceded by a forward slash as shown below
with few tags:
Start Tag Content End Tag
<p> This is paragraph content. </p>
So here <p>....</p> is an HTML element, <h1>...</h1> is another HTML element. There are
some HTML elements which don't need to be closed, such as <img.../>, <hr /> and <br />
elements. These are known as void elements.
21
HTML documents consists of a tree of these elements and they specify how HTML
documents should be built, and what kind of content should be placed in what part of an
HTML document.
An HTML element is defined by a starting tag. If the element contains other content, it ends
with a closing tag.
For example, <p> is starting tag of a paragraph and </p> is closing tag of the same paragraph
but <p>This is paragraph</p> is a paragraph element.
Example :
<!DOCTYPE html>
<html>
<head>
<title>Nested Elements Example</title>
</head>
<body>
<h1>This is <i>italic</i> heading</h1>
<p>This is <u>underlined</u> paragraph</p>
</body>
</html>
HTML – ATTRIBUTES
We have seen few HTML tags and their usage like heading tags <h1>, <h2>, paragraph tag
<p> and other tags. We used them so far in their simplest form, but most of the HTML tags
can also have attributes, which are extra bits of information.
22
An attribute is used to define the characteristics of an HTML element and is placed inside the
element's opening tag. All attributes are made up of two parts: a name and a value:
The name is the property you want to set. For example, the paragraph <p> element in the
example carries an attribute whose name is align, which you can use to indicate the alignment
of paragraph on the page.
The value is what you want the value of the property to be set and always put within
quotations. The below example shows three possible values of align attribute: left, center and
right.
Attribute names and attribute values are case-insensitive. However, the World Wide Web
Consortium (W3C) recommends lowercase attributes/attribute values in their HTML 4
recommendation.
Example :
<!DOCTYPE html>
<html>
<head>
<title>Align Attribute Example</title>
</head>
<body>
<p align="left">This is left aligned</p>
<p align="center">This is center aligned</p>
<p align="right">This is right aligned</p>
</body>
</html>
This will display the following result:
HTML – FORMATTING
If you use a word processor, you must be familiar with the ability to make text bold,
italicized, or underlined; these are just three of the ten options available to indicate how text
can appear in HTML and XHTML.
Bold Text
Anything that appears within <b>...</b> element, is displayed in bold as shown below:
Example :
<!DOCTYPE html>
<html>
<head>
<title>Bold Text Example</title>
</head>
<body>
<p>The following word uses a <b>bold</b> typeface.</p>
</body>
</html>
This will produce the following result:
Italic Text
Anything that appears within <i>...</i> element is displayed in italicized as shown below:
Example :
<!DOCTYPE html>
<html>
<head>
<title>Italic Text Example</title>
</head>
<body>
24
Underlined Text
Anything that appears within <u>...</u> element, is displayed with underline as shown
below:
Example :
<!DOCTYPE html>
<html>
<head>
<title>Underlined Text Example</title>
</head>
<body>
<p>The following word uses a <u>underlined</u> typeface.</p>
</body>
</html>
This will produce the following result:
Strike Text
Anything that appears within <strike>...</strike> element is displayed with strikethrough,
which is a thin line through the text as shown below:
Example :
<!DOCTYPE html>
25
<html>
<head>
<title>Strike Text Example</title>
</head>
<body>
<p>The following word uses a <strike>strikethrough</strike> typeface.</p>
</body>
</html>
This will produce the following result:
Superscript Text
The content of a <sup>...</sup> element is written in superscript; the font size used is the
same size as the characters surrounding it but is displayed half a character's height above the
other characters.
Example :
<!DOCTYPE html>
<html>
<head>
<title>Superscript Text Example</title>
</head>
<body>
<p>The following word uses a <sup>superscript</sup> typeface.</p>
</body>
</html>
This will produce the following result:
The following word uses a superscript typeface.
26
Subscript Text
The content of a <sub>...</sub> element is written in subscript; the font size used is the same
as the characters surrounding it, but is displayed half a character's height beneath the other
characters.
Example :
<!DOCTYPE html>
<html>
<head>
<title>Subscript Text Example</title>
</head>
<body>
<p>The following word uses a <sub>subscript</sub> typeface.</p>
</body>
</html>
Deleted Text
Anything that appears within <del>...</del> element, is displayed as deleted text.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Deleted Text Example</title>
</head>
<body>
<p>I want to drink <del>cola</del> <ins>wine</ins></p>
</body>
</html>
27
Larger Text
The content of the <big>...</big> element is displayed one font size larger than the rest of the
text surrounding it as shown below:
Example :
<!DOCTYPE html>
<html>
<head>
<title>Larger Text Example</title>
</head>
<body>
<p>The following word uses a <big>big</big> typeface.</p>
</body>
</html>
Smaller Text
The content of the <small>...</small> element is displayed one font size smaller than the rest
of the text surrounding it as shown below:
Example :
<!DOCTYPE html>
<html>
<head>
<title>Smaller Text Example</title>
</head>
<body>
<p>The following word uses a <small>small</small> typeface.</p>
28
</body>
</html>
Emphasized Text
Anything that appears within <em>...</em> element is displayed as emphasized text.
Example :
<!DOCTYPE html>
<html>
<head>
<title>Emphasized Text Example</title>
</head>
<body>
<p>The following word uses a <em>emphasized</em> typeface.</p>
</body>
</html>
Marked Text
Anything that appears with-in <mark>...</mark> element, is displayed as marked with yellow
ink.
29
Example :
<!DOCTYPE html>
<html>
<head>
<title>Marked Text Example</title>
</head>
<body>
<p>The following word has been <mark>marked</mark> with yellow</p>
</body>
</html>
This will produce the following result:
Strong Text
Anything that appears within <strong>...</strong> element is displayed as important text.
Example :
<!DOCTYPE html>
<html>
<head>
<title>Strong Text Example</title>
</head>
<body>
<p>The following word uses a <strong>strong</strong> typeface.</p>
</body>
</html>
Address Text
The <address>...</address> element is used to contain any address.
Example :
<!DOCTYPE html>
<html>
<head>
<title>Address Example</title>
</head>
<body>
<address>388A, Road No 22, Jubilee Hills - Hyderabad</address>
</body>
</html>
4. CSS
What is CSS ?
Cascading Style Sheets, fondly referred to as CSS, is a simple design language intended to
simplify the process of making web pages presentable.
CSS handles the look and feel part of a web page. Using CSS, you can control the color of
the text, the style of fonts, the spacing between paragraphs, how columns are sized and laid
out, what background images or colors are used, as well as a variety of other effects.
CSS is easy to learn and understand but it provides a powerful control over the presentation
of an HTML document. Most commonly, CSS is combined with the markup languages
HTML or XHTML.
Advantages of CSS
CSS saves time - You can write CSS once and then reuse the same sheet in multiple
HTML pages. You can define a style for each HTML element and apply it to as many
web pages as you want.
Pages load faster - If you are using CSS, you do not need to write HTML tag
attributes every time. Just write one CSS rule of a tag and apply it to all the
occurrences of that tag. So, less code means faster download times.
Easy maintenance - To make a global change, simply change the style, and all the
elements in all the web pages will be updated automatically.
Superior styles to HTML - CSS has a much wider array of attributes than HTML, so
you can give a far better look to your HTML page in comparison to HTML attributes.
Multiple Device Compatibility - Style sheets allow content to be optimized for more
than one type of device. By using the same HTML document, different versions of a
website can be presented for handheld devices such as PDAs and cellphones or for
printing.
These ratified specifications are called recommendations because the W3C has no control
over the actual implementation of the language. Independent companies and organizations
create that software.
NOTE: The World Wide Web Consortium or W3C is a group that makes recommendations
about how the Internet works and how it should evolve.
CSS Versions
Cascading Style Sheets level 1 (CSS1) came out of W3C as a recommendation in
December 1996. This version describes the CSS language as well as a simple visual
formatting model for all the HTML tags.
CSS2 became a W3C recommendation in May 1998 and builds on CSS1. This version adds
support for media-specific style sheets e.g. printers and aural devices, downloadable fonts,
element positioning and tables.
CSS ─ SYNTAX
A CSS comprises of style rules that are interpreted by the browser and then applied to the
corresponding elements in your document. A style rule is made of three parts:
Selector: A selector is an HTML tag at which a style will be applied. This could be
any tag like <h1> or <table> etc.
Property: A property is a type of attribute of HTML tag. Put simply, all the HTML
attributes are converted into CSS properties. They could be color, border, etc.
Value: Values are assigned to properties. For example, color property can have the
value either red or #F1F1F1 etc.
You can put CSS Style Rule Syntax as follows:
selector { property: value }
Example:
Here table is a selector and border is a property and the given value 1px solid #C00 is the
value of that property.
You can define selectors in various simple ways based on your comfort. Let me put these
selectors one by one.
The Type Selectors
33
This is the same selector we have seen above. Again, one more example to give a color to
all level 1 headings:
h1 {
color: #36CFFF;
}
You can apply more than one class selectors to a given element. Consider the following
example:
<p class="center bold">
This para will be styled by the classes center and bold.
</p>
The ID Selectors
You can define style rules based on the id attribute of the elements. All the elements having
that id will be formatted according to the defined rule.
#black {
color: #000000;
}
This rule renders the content in black for every element with id attribute set to black in our
document. You can make it a bit more particular. For example:
h1#black {
color: #000000;
}
This rule renders the content in black for only <h1> elements with id attribute set to black.
The true power of id selectors is when they are used as the foundation for descendant
selectors. For example:
#black h2 {
color: #000000;
}
In this example, all level 2 headings will be displayed in black color when those headings
will lie within tags having id attribute set to black.
This rule will render all the paragraphs in black if they are a direct child of the <body>
element. Other paragraphs put inside other elements like <div> or <td> would not have any
effect of this rule.
For a while, don't bother about the properties mentioned in the above block. These
properties will be explained in the coming chapters and you can find the complete detail
about properties in CSS References.
Grouping Selectors
You can apply a style to many selectors if you like. Just separate the selectors with a
comma, as given in the following example:
h1, h2, h3 {
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}
This define style rule will be applicable to h1, h2 and h3 element as well. The order of the
list is irrelevant. All the elements in the selector will have the corresponding declarations
applied to them.
You can combine the various class selectors together as shown below:
#content, #footer, #supplement {
position: absolute;
left: 510px;
width: 200px;
}
CSS ─ INCLUSION
There are four ways to associate styles with your HTML document. Most commonly used
methods are inline CSS and External CSS.
Attributes
Attributes associated with <style> elements are:
Example :
CSS Comments
Many times, you may need to put additional comments in your style sheet blocks. So, it is
very easy to comment any part in the style sheet. You can simply put your comments
inside /*.....this is a comment in style sheet.....*/.
You can use /* ....*/ to comment multi-line blocks in similar way you do in C and C++
programming languages.
Example :
/* This is an external style sheet file */
h1, h2, h3 {
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}
/* end of style rules. */
We have listed out all the CSS Measurement Units along with proper Examples:
CSS ─ COLORS
40
CSS uses color values to specify a color. Typically, these are used to set a color either for the
foreground of an element (i.e., its text) or for the background of the element. They can also
be used to affect the color of borders and other decorative effects.
You can specify your color values in various formats. Following table lists all the possible
formats:
5. XML
41
There are three important characteristics of XML that make it useful in a variety of
systems and solutions:
XML is extensible: XML allows you to create your own self-descriptive tags or
language, that suits your application.
XML carries the data, does not present it: XML allows you to store the data
irrespective of how it will be presented.
XML is a public standard: XML was developed by an organization called the World
Wide Web Consortium (W3C) and is available as an open standard.
XML Usage
A short list of XML usage says it all:
XML can work behind the scene to simplify the creation of HTML documents for
large web sites.
XML can be used to exchange the information between organizations and
systems.
XML can be used for offloading and reloading of databases.
XML can be used to store and arrange the data, which can customize your data
handling needs.
XML can easily be merged with style sheets to create almost any desired output.
Virtually, any type of data can be expressed as an XML document.
What is Markup ?
XML is a markup language that defines set of rules for encoding documents in a format
that is both human-readable and machine-readable. So, what exactly is a markup
language? Markup is information added to a document that enhances its meaning in
certain ways, in that it identifies the parts and how they relate to each other. More
42
specifically, a markup language is a set of symbols that can be placed in the text of a
document to demarcate and label the parts of that document.
Following example shows how XML markup looks, when embedded in a piece of text:
<message>
<text>Hello, world!</text>
</message>
This snippet includes the markup symbols, or the tags such as <message>...</message>
and <text>... </text>. The tags <message> and </message> mark the start and the end of
the XML code fragment. The tags <text> and </text> surround the text Hello, world!.
XML – Syntax
In this chapter, we will discuss the simple syntax rules to write an XML document. Following
is a complete XML document:
<?xml version="1.0"?>
<contact-info>
<name>Tanmay Patil</name>
<company>TutorialsPoint</company>
<phone>(011) 123-4567</phone>
</contact-info>
You can notice, there are two kinds of information in the above example:
Markup, like <contact-info>
The text, or the character data, Tutorials Point and (040) 123-4567
The following diagram depicts the syntax rules to write different types of markup and text in
an XML document.
43
XML Declaration
The XML document can optionally have an XML declaration. It is written as follows:
<?xml version="1.0" encoding="UTF-8"?>
Where version is the XML version and encoding specifies the character encoding used in the
document.
Element Syntax: Each XML-element needs to be closed either with start or with end
elements as shown below:
44
<element>....</element>
or in simple-cases, just this way:
<element/>
Nesting of Elements: An XML-element can contain multiple XML-elements as its children,
but the children elements must not overlap. i.e., an end tag of an element must have the same
name as that of the most recent unmatched start tag.
The following example shows incorrect nested tags:
<?xml version="1.0"?>
<contact-info>
<company>TutorialsPoint
<contact-info>
</company>
The following example shows correct nested tags:
<?xml version="1.0"?>
<contact-info>
<company>TutorialsPoint</company>
<contact-info>
Root Element: An XML document can have only one root element. For example, following
is not a correct XML document, because both the x and y elements occur at the top level
without a root element:
<x>...</x>
<y>...</y>
The following example shows a correctly formed XML document:
<root>
<x>...</x>
<y>...</y>
</root>
Case Sensitivity: The names of XML-elements are case-sensitive. That means the name of
the start and the end elements need to be exactly in the same case.
For example, <contact-info> is different from <Contact-Info>.
XML Attributes
45
An attribute specifies a single property for the element, using a name/value pair. An XML-
element can have one or more attributes. For example:
<a href="http://www.tutorialspoint.com/">Tutorialspoint!</a>
Attribute names in XML (unlike HTML) are case sensitive. That is, HREF and href
are considered two different XML attributes.
Same attribute cannot have two values in a syntax. The following example shows
incorrect syntax because the attribute b is specified twice:
<a b="x" c="y" b="z">....</a>
Attribute names are defined without quotation marks, whereas attribute values must
always appear in quotation marks. Following example demonstrates incorrect xml
syntax:
<a b=x>....</a>
In the above syntax, the attribute value is not defined in quotation marks.
XML References
References usually allow you to add or include additional text or markup in an XML
document. References always begin with the symbol "&" which is a reserved character and
end with the symbol ";". XML has two types of references:
Entity References: An entity reference contains a name between the start and the end
delimiters. For example, & where amp is name. The name refers to a predefined
string of text and/or markup.
Character References: These contain references, such as A, contains a hash
mark (“#”) followed by a number. The number always refers to the Unicode code of a
character. In this case, 65 refers to alphabet "A".
XML Text
The names of XML-elements and XML-attributes are case-sensitive, which means the name
of start and end elements need to be written in the same case. To avoid character encoding
problems, all XML files should be saved as Unicode UTF-8 or UTF-16 files.
46
Whitespace characters like blanks, tabs and line-breaks between XML-elements and between
the XML-attributes will be ignored.
Some characters are reserved by the XML syntax itself. Hence, they cannot be used directly.
To use them, some replacement-entities are used, which are listed below:
XML – Documents
An XML document is a basic unit of XML information composed of elements and other
markup in an orderly package. An XML document can contain a wide variety of data. For
example, database of numbers, numbers representing molecular structure or a mathematical
equation.
XML Document Example
A simple document is shown in the following example:
<?xml version="1.0"?>
<contact-info>
<name>Tanmay Patil</name>
<company>TutorialsPoint</company>
<phone>(011) 123-4567</phone>
</contact-info>
The following image depicts the parts of XML document.
47
You can learn more about XML declaration in this chapter : XML Declaration.
XML – Declaration
This chapter covers XML declaration in detail. XML declaration contains details that prepare
an XML processor to parse the XML document. It is optional, but when used, it must appear
in the first line of the XML document.
Syntax:
Following syntax shows XML declaration:
<?xml
version="version_number"
encoding="encoding_declaration"
standalone="standalone_status"
?>
Each parameter consists of a parameter name, an equals sign (=), and parameter value inside
a quote. Following table shows the above syntax in detail:
Parameter Parameter_value Parameter_description
Rules
An XML declaration should abide with the following rules:
If the XML declaration is present in the XML, it must be placed as the first line in the
XML document.
If the XML declaration is included, it must contain version number attribute.
The parameter names and values are case-sensitive.
The names are always in lower case.
The order of placing the parameters is important. The correct order is: version,
encoding and standalone.
Either single or double quotes may be used.
The XML declaration has no closing tag, i.e. </?xml>
XML – Tags
49
Let us learn about one of the most important part of XML, the XML tags. XML tags form
the foundation of XML. They define the scope of an element in XML. They can also be used
to insert comments, declare settings required for parsing the environment, and to insert
special instructions.
We can broadly categorize XML tags as follows:
Start Tag
The beginning of every non-empty XML element is marked by a start-tag. Following is an
example of start-tag:
<address>
End Tag
Every element that has a start tag should end with an end-tag. Following is an example of
end-tag:
</address>
Note, that the end tags include a solidus ("/") before the name of an element.
Empty Tag
The text that appears between start-tag and end-tag is called content. An element which has
no content is termed as empty. An empty element can be represented in two ways as follows:
A start-tag immediately followed by an end-tag as shown below:
<hr></hr>
A complete empty-element tag is as shown below:
<hr />
Empty-element tags may be used for any element which has no content.