unit 2 wt
unit 2 wt
• HTML stands for Hyper Text MarkupLanguage Paragraphs are defined with the <p> tag. Think of a paragraph as a block of text. You can use the
• An HTML file is a text file containing small markuptags align attribute with a paragraph tag as well.
• The markup tags tell the Web browser how to display thepage
<p align="left">This is a paragraph</p>
• An HTML file must have an htm or html fileextension. <p align="center">this is another paragraph</p>
HTML Tags:- HTML tags are used to mark-up HTML elements .HTML tags are surrounded by
Note: You must indicate paragraphs with <p> elements. A browser ignores any
the two characters < and >. The surrounding characters are called angle brackets. HTML tags
indentations or blank lines in the source text. Without <p> elements, the documentbecomes
normally come in pairs like and The first tag in a pair is the start tag, the second tag is the end
one large paragraph. HTML automatically adds an extra blank line before and after a paragraph.
tag . The text between the start and end tags is the element content . HTML tags are not case
sensitive, <B>means the same as<b>.
Line Breaks:-
The most important tags in HTML are tags that define headings, paragraphs and line breaks. The <br> tag is used when you want to start a new line, but don't want to start a new paragraph.
Tag Description The <br> tag forces a line break wherever you place it. It is similar to single spacing in a
<!DOCTYPE...> This tag defines the document type and HTML version. document.
This Code output
<html> This tag encloses the complete HTML document and mainly comprises of
<p>This <br> is a para<br> graph with This
document header which is represented by <head>...</head> and document
body which is represented by <body>...</body> tags. is a para
line breaks</p> graph with line breaks
<head> This tag represents the document's header which can keep other HTML tags
like <title>, <link> etc.
Horizontal Rule The element is used for horizontal rules that act as dividers between sections
<title> The <title> tag is used inside the <head> tag to mention the document title.
like this:
<body> This tag represents the document's body which keeps other HTML tags like
<h1>, <div>, <p> etc. The horizontal rule does not have a closing tag. It takes attributes such as align and width
<p> This tag represents a paragraph. Code Output
<h1> to <h6> Defines header 1 to header 6 <hr width="50%" align="center">
Lists:-HTML offers web authors three ways for specifying lists of information. HTML Definition Lists:- HTML and XHTML supports a list style which is called definition
All lists must contain one or more list elements. Lists are of three types lists where entries are listed like in a dictionary or encyclopedia. The definition list is the ideal
1) Un ordered list way to present a glossary, list of terms, or other name/value list. Definition List makes use of
2)Ordered List following three tags.
3)Definitionlist 1). <dl> - Defines the start of the list
2). <dt> - A term
HTML Unordered Lists:An unordered list is a collection of related items that have no special 3). <dd> - Termdefinition
order or sequence. This list is created by using HTML <ul> tag. Each item in the list is marked 4). </dl> - Defines the end of thelist
with a bullet.
Example
<!DOCTYPE html>
<html>
<!DOCTYPE html> <head>
<html> <title>HTML Definition List</title>
<head> </head>
<title>HTML Unordered List</title> <body>
</head> <dl>
<body> <dt><b>HTML</b></dt><dd>This stands for Hyper Text Markup Language</dd>
<ul> <li>Beetroot</li> <dt><b>HTTP</b></dt><dd>This stands for Hyper Text Transfer Protocol</dd>
<li>Ginger</li><li>Potato</li> </dl>
<li>Radish</li> </body>
</ul> </html>
</body>
</html>
HTML tables:
The HTML tables allow web authors to arrange data like text, images, links, other tables, etc.
into rows and columns of cells. The HTML tables are created using the <table>tag inwhich the
HTML Ordered Lists:- items are numbered list instead of bulleted, This list is created by using <tr>tag is used to create table rows and <td>tag is used to create data cells.
<ol>tag.
Example:
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>HTML Ordered List</title> <title>HTML Tables</title>
</head> </head>
<body> <body>
<ol> <table border="1">
<li>Beetroot</li> <tr>
<li>Ginger</li> <td>Row 1, Column 1</td><td>Row 1, Column 2</td>
<li>Potato</li> </tr>
<li>Radish</li> <tr><td>Row 2, Column 1</td><td>Row 2, Column 2</td>
</ol> </tr>
</body> </table>
</html> </body>
Web Technologies Page 9 WebTechnolog<ie/h
s tml> Page 10
top Align the image at the top
Images are very important to beautify as well as to depict many complex concepts in simple way
on your web page.
Insert Image:
insert any image in the web page by using <img>tag.
<img align="left|right|middle|top|bottom">
Attribute Values
Value Description
WebTechnologies Page11
3) Multi-line text input controls - This is used when the user is required to give details that may
belongerthanasinglesentence.Multi-lineinputcontrolsarecreatedusing HTML
HTML Form Controls: <textarea> tag.
There are different types of form controls that you can use to collect data using HTML form:
➢ Text InputControls
➢ Checkboxes Controls <!DOCTYPE html>
➢ Radio BoxControls <html>
➢ Select BoxControls <head>
➢ File Selectboxes <title>Multiple-Line Input Control</title>
➢ Hidden Controls </head>
➢ ClickableButtons <body>
➢ Submit and ResetButton <form> Description: <br />
<textarea rows="5" cols="50" name="description"> Enter description here... </textarea>
Text Input Controls:-
</form>
There are three types of text input used on forms:
</body>
1) Single-line text input controls - This control is used for items that require only one </html>
line of user input, such as search boxes or names. They are created usingHTML
<input>tag. Checkboxes Controls:-
Checkboxes are used when more than one option is required to be selected. They are also
<input type="text">defines a one-line input field for text input: created using HTML <input> tag but type attribute is set to checkbox.
Here is an example HTML code for a form with two checkboxes:
Example:
<!DOCTYPE html>
<form> <html><head><title>Checkbox Control</title></head>
Firstname:<br> <body>
<input type="text"name="firstname"><br> <form>
Lastname:<br> <input type="checkbox" name="C++" value="on"> C++
<input type="text" name="lastname"> <br>
</form> <input type="checkbox" name="C#" value="on"> C#
<br>
<input type="checkbox" name="JAVA" value="on"> JAVA
2) Password input controls - This is also a single-line text input but it masks the character as </form>
soon as a user enters it. They are also created using HTML <input>tag. </body></html>
Input Type Password
Radio Button Control:-
Radio buttons are used when out of many options, just one option is required to be selected.
<input type="password">defines a password field: They are also created using HTML <input> tag but type attribute is set toradio.
<!DOCTYPE html>
<html><head><title>Radio Box Control</title></head>
<form> <body><p>Select a Course</p>
User name:<br> <form>
<input type="text" name="username"><br> <input type="radio" name="subject" value="C++"> C++
User password:<br> <br>
<input type="radio" name="subject" value="JAVA"> JAVA
<input type="password" name="psw">
<br>
</form> <input type="radio" name="subject" value="HTML"> HTML
</form> </body></html>
<!DOCTYPE html>
<html>
<head>
<title>Select Box Control</title>
</head> Button Controls:-
<body> There are various ways in HTML to create clickable buttons. You can also create a clickable
<form>
button using <input> tag by setting its type attribute to button. The type attribute can take the
<select name="dropdown">
<option value="C++" selected>C++</option> following values:
<option value="JAVA">JAVA</option>
<option value="HTML">HTML</option>
</select>
</form>
</body>
</html>
File Select boxes:- If you want to allow a user to upload a file to your web site, you will need to
use a file upload box, also known as a file select box. This is also created using the <input>
element but type attribute is set to file.
<!DOCTYPE html>
<html>
<head> <!DOCTYPE html>
<title>File Upload Box</title> <html>
</head> <head>
<body> <title>File Upload Box</title>
<p>File Upload Box</p> </head>
<form>
<body>
<input type="file" name="fileupload" accept="image/*" />
</form> <form>
</body> <input type="submit" name="submit" value="Submit" />
</html> <input type="reset" name="reset" value="Reset" />
<input type="button" name="ok" value="OK" />
<input type="image" name="imagebutton" src="test1.png" />
</form>
Hidden Controls:- Hidden form controls are used to hide data inside the page which later on can </body></html>
be pushed to the server. This control hides inside the code and does not appear on the actual
page. For example, following hidden form is being used to keep current page number. When a
user will click next page then the value of hidden control will be sent to the web server and there
it will decide which page will be displayed next based on the passed currentpage. HTML frames: These are used to divide your browser window into multiple sections where
each section can load a separate HTML document. A collection of frames in the browser window
<html><head> <title>File Upload Box</title> </head> is known as a frameset. The window is divided into frames in a similar way the tables
<body>
<form>
areorganized: into rows andcolumns.
<p>This is page 10</p> To use frames on a page we use <frameset> tag instead of <body> tag. The <frameset>
<input type="hidden" name="pagename" value="10" /> tag defines, how to divide the window into frames. The rows attribute of <frameset> tag defines
<input type="submit" name="submit" value="Submit" />
<input type="reset" name="reset" value="Reset" />
Web Technologies</form> </body> </html> Web Technologies
horizontal frames and cols attribute defines vertical frames. Each frame is indicated by <frame>
tag and it defines which HTML document shall open into the frame.
Internal CSS: An internal CSS is used to define a style for a single HTML page. An internal
CSS is defined in the <head> section of an HTML page, within a <style> element:
Note: HTML <frame>Tag. Not Supported in HTML5.
<html>
<head>
<frameset cols="25%,50%,25%"> <style>
<framesrc="frame_a.htm"> body {background-color: powderblue;}
<framesrc="frame_b.htm"> h1 {color: blue;}
<framesrc="frame_c.htm"> p {color:red;}
</frameset> </style>
</head>
<body>
<!DOCTYPE html> <h1>This is aheading</h1>
<html>
<p>This is aparagraph.</p>
<head>
</body>
<title>Page Title</title>
</html>
</head>
<body>
<iframe src="sample1.html" height="400" width="400"frameborder="1">
<h1>This is aHeading</h1> External CSS:-
<p>This is aparagraph.</p> An external style sheet is used to define the style for many HTML pages. With an external style
</iframe> sheet, you can change the look of an entire web site, by changing one file! To use an external
</body> style sheet, add a link to it in the <head> section of the HTML page:
</html>
CSS stands for Cascading Style Sheets <html>
CSS describes how HTML elements are to be displayed on screen, paper, or in other media. <head>
CSS saves a lot of work. It can control the layout of multiple web pages all at once. <link rel="stylesheet" href="styles.css">
CSS can be added to HTML elements in 3 ways: </head>
<body>
➢ Inline - by using the style attribute in HTMLelements <h1>This is aheading</h1>
➢ Internal - by using a <style> element in the <head>section <p>This is aparagraph.</p>
➢ External - by using an external CSSfile </body>
Inline CSS </html>
An inline CSS is used to apply a unique style to a single HTML element.
An inline CSS uses the style attribute of an HTML element. An external style sheet can be written in any text editor. The file must not contain any HTML
This example sets the text color of the <h1> element to blue: code, and must be saved with a .css extension.
Here is how the "styles.css" looks:
<h1 style="color:blue;">This is a Blue Heading</h1>
body { background-color: powderblue; }
h1 { color:blue; }
<html> <head> <title>Page Title</title></head>
<body> p { color:red; }
<h1 style="color:blue;">This is a Blue Heading</h1>
</body>
</html>
Web Technologies Page 17
WebTechnologies Page18
XML - XML stands for Extensible Mark-up Language, developed by W3C in 1996. It is a
CSS Fonts: The CSS color property defines the text color to be used. text-based mark-up language derived from Standard Generalized Mark-up Language
The CSS font-family property defines the font to be used.
(SGML). XML 1.0 was officially adopted as a W3C recommendation in 1998. XML was
The CSS font-size property defines the text size to be used.
designed to carry data, not to display data. XML is designed to be self-descriptive. XML is a
subset of SGML that can define your own tags. A Meta Language and tags describe the
<html>
content. XML Supports CSS, XSL, DOM. XML does not qualify to be a programming
<head>
<style> language as it does not performs any computation or algorithms. It is usually stored in a
h1 { simple text file and is processed by special software that is capable of interpretingXML.
color: blue;
font-family: verdana; The Difference between XML and HTML
font-size: 300%; 1. HTML is about displaying information, where asXML is about carrying information. In
} other words, XML was created to structure, store, and transport information. HTML was
p{ designed to display thedata.
color: red; 2. Using XML, we can create own tags where as in HTML it is not possible instead it offers
font-family: courier;
several built intags.
font-size: 160%;
} 3. XML is platform independent neutral and languageindependent.
</style> 4. XML tags and attribute names are case-sensitive where as in HTML it isnot.
</head> 5. XML attribute values must be single or double quoted where as in HTML it is not
<body> compulsory.
<h1>This is aheading</h1> 6. XML elements must be properlynested.
<p>This is aparagraph.</p>
7. All XML elements must have a closingtag.
</body>
</html> Well Formed XML Documents
A "Well Formed" XML document must have the following correct XML syntax:
CSS Border: The CSS border property defines a border around an HTML element. - XML documents must have a rootelement
CSS Padding: The CSS padding property defines a padding (space) between the text and the - XML elements must have a closing tag(start tag must have matching endtag).
border. - XML tags are casesensitive
- XML elements must be properly nestedEx:<one><two>Hello</two></one>
CSS Margin: The CSS margin property defines a margin (space) outside the border. - XML attribute values must bequoted
XML with correct syntax is "Well Formed" XML. XML validated against a DTD is "Valid"
<html><head> XML
<style>h
1{
color: blue;
font-family: verdana;
font-size: 300%; }
p{
color: red; font-size: 160%; border: 2px solid powderblue; padding: 30px; margin: 50px; }
</style>
</head>
<body>
<h1>This is aheading</h1>
<p>This is aparagraph.</p>
</body>
</html>
Web Technologies
What is Markup? Syntax 4: <!ELEMENT element-name (ANY)>
XML is a markup language that defines set of rules for encoding documents in a format that The keyword ANY declares an element with any content.
is both human-readable andmachine-readable. Example:
<!ELEMENT note (#PCDATA)>
Example for XML Document
Elements with children (sequences)
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!—xml declaration-->
Elements with one or more children are defined with the name of the children elements inside
<note>
the parentheses:
<to>MRCET</to>
<from>MRGI</from> <!ELEMENT parent-name (child-element-name)>EX:<!ELEMENT student (id)>
<heading>KALPANA</heading> <!ELEMENT id (#PCDATA)> or
<body>Hello, world! </body> <!ELEMENT element-name(child-element-name,child-element-name,. ..... )>
</note> Example: <!ELEMENT note (to,from,heading,body)>
• Xml document begins with XML declaration statement: <? xml version="1.0" When children are declared in a sequence separated by commas, the children must appear in
encoding="ISO-8859-1"?>. the same sequence in the document. In a full declaration, the children must also be declared,
• The next line describes the root element of the document:<note>. and the children can also have children. The full declaration of the note document will be:
• This element is "the parent" of all otherelements. <!ELEMENT note (to,from,heading,body)>
• The next 4 lines describe 4child elements of the root: to, from, heading, and body. And <!ELEMENTto (#CDATA)>
finally the last line defines the end of the root element : </note>. <!ELEMENTfrom (#CDATA)>
• The XML declaration has no closing tag i.e.</?xml> <!ELEMENT heading (#CDATA)>
• The default standalone value is set to no. Setting it to yes tells the processor there are no <!ELEMENTbody (#CDATA)>
external declarations (DTD) required for parsing the document. The file name extension
used for xml program is.xml. 2. Tags
Valid XML document Tags are used to markup elements. A starting tag like <element_name> mark up the
If an XML document is well-formed and has an associated Document Type Declaration beginning of an element, and an ending tag like </element_name> mark up the end of an
(DTD), then it is said to be a valid XML document. We will study more about DTD in the element.
chapter XML - DTDs. Examples:
A body element: <body>body text in between</body>.
XML DTD A message element: <message>some message in between</message>
Document Type Definition purpose is to define the structure of an XML document. It defines
the structure with a list of defined elements in the xml document. Using DTD we can specify 3. Attribute: The attributes are generally used to specify the values of the element. These are
the various elements types, attributes and their relationship with one another. Basically DTD specified within the double quotes. Ex: <flagtype=‖true‖>
is used to specify the set of rules for structuring data in any XML file. 4. Entities
Why use a DTD? Entities as variables used to define common text. Entity references are references to entities.
XML provides an application independent way of sharing data. With a DTD, independent Most of you will known the HTML entity reference: " " that is used to insert an extra
groups of people can agree to use a common DTD for interchanging data. Your application space in an HTML document. Entities are expanded when a document is parsed by an XML
can use a standard DTD to verify that data that you receive from the outside world is valid. parser.
You can also use a DTD to verify your own data. The following entities are predefined in XML:
< (<), >(>), &(&), "(") and '(').
DTD - XML building blocks
Various building blocks of XML are- 5. CDATA: It stands for character data. CDATA is text that will NOT be parsed by a
1. Elements: The basic entity is element. The elements are used for defining the tags. The parser. Tags inside the text will NOT be treated as markup and entities will not beexpanded.
elements typically consist of opening and closing tag. Mostly only one element is used to 6. PCDATA: It stands for Parsed Character Data(i.e., text). Any parsed character data should
define a singletag. not contain the markup characters. The markup characters are < or > or &. If we want to use
Syntax1: <!ELEMENT element-name (element-content)> these characters then make use of < , > or &. Think of character data as the text
Syntax 2: <!ELEMENT element-name (#CDATA)> found between the start tag and the end tag of an XML element. PCDATA is text that will be
#CDATA means the element contains character data that is not supposed to be parsed by a parsed by a parser. Tags inside the text will be treated as markup and entities will be
parser. or expanded.
Syntax 3: <!ELEMENT element-name (#PCDATA)>
#PCDATA means that the element contains data that IS going to be parsed by a parser. or <!DOCTYPE note
The XML DOM, on the other hand, also provides an API that allows a developer to add, edit,
move, or remove nodes in the tree at any point in order to create an application. A DOM
parser creates a tree structure in memory from the input document and then waits for requests
from client. A DOM parser always serves the client application with the entire document no
matter how much is actually needed by the client. With DOM parser, method calls in client
application have to be explicit and forms a kind of chained method calls.
Document Object Model is for defining the standard for accessing and manipulating XML
documents. XML DOM is used for
DOM based XML Parsing:(tree based)
• Loading the xmldocument JAXP is a tool, stands for Java Api for Xml Processing, used for accessing and manipulating
• Accessing the xmldocument xml document in a tree based manner.
• Deleting the elements of xmldocument The following DOM javaClasses are necessary to process the XML document:
• Changing the elements of xml document • DocumentBuilderFactory class creates the instance ofDocumentBuilder.
According to the DOM, everything in an XML document is a node. It considers • DocumentBuilder produces a Document (a DOM) that conforms to the DOM specification.
The following methods and properties are necessary to process the XMLdocument:
• The entire document is a documentnode
Property Meaning
• Every XML element is an elementnode nodeName Finding the name of the node
• The text in the XML elements are textnodes nodeValue Obtaining value of the node
• Every attribute is an attributenode parentNode To get parnet node
• Comments are comment nodes childNodes Obtain child nodes
Attributes For getting the attributes values
The W3C DOM specification is divided into three major parts:
DOM Core- This portion defines the basic set of interfaces and objects for any structured Method Meaning
documents. getElementByTagName(name) To access the element by specifying its name
XML DOM- This part specifies the standard set of objects and interfaces for XML appendChild(node) To insert a child node
documents only. removeChild(node) To remove existing child node
HTML DOM- This part specifies the objects and interfaces for HTML documents only.
DOM Levels <html>
<body> BODY
• Level 1 Core: W3C Recommendation, October1998 <h1>Heading 1</h1>
lastChild
parentNode
<p>Paragraph.</p>
✓ It has feature for primitive navigation and manipulation of XMLtrees
firstChild
HEAD
<h2>Heading 2</h2>
parentNode
parentNode
parentNode
parentNode
P
firstChild
firstChild
firstChild
firstChild
lastChild
lastChild
lastChild
lastChild
• Level 3 Core: W3C Working Draft, April2002
#text
H2
✓ It supports: Schemas, XPath, XSL, XSLT #text
DOM in JAVA
DOM interfaces
The DOM defines several Java interfaces. Here are the most common interfaces:
• Node - The base datatype of theDOM.
• Element - The vast majority of the objects you'll deal with areElements.
}}
PHP started out as a small open source project that evolved as more and more people found out
how useful it was. Rasmus Lerdorf unleashed the first version of PHP way back in 1994.
Web Technologies