Академический Документы
Профессиональный Документы
Культура Документы
UNIT-1 XHTML
Introduction to XHTML
XHTML stands for EXtensible HyperText Markup Language XHTML is almost identical to HTML 4.01 XHTML is a stricter and cleaner ersion of HTML XHTML is HTML defined as an XML application XHTML is a !"# $ecommendation
XHTML - Why?
XHTML is a combination of HTML and XML %Extensible Markup Language&. XHTML consists of all t'e elements in HTML( combined )it' t'e strict syntax of XML. Many pages on t'e internet contain *bad* HTML.
T'e follo)ing HTML code )ill )ork +ust fine if you ie) it in a bro)ser %e en if it does ,-T follo) t'e HTML rules&. /'tml0 /'ead0 /title0T'is is bad HTML/1title0 /body0 /'102ad HTML /p0T'is is a paragrap' /1body0 XML is a markup language )'ere e eryt'ing must be marked up correctly( )'ic' results in *)ell3formed* documents. 4o in XHTML 3 XML is designed to describe data( and HTML is designed to display data. T'erefore 3 by combining t'e strengt's of HTML and XML( !"# recommended a markup language t'at is useful no) and in t'e future 3 XHTML.
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
<
Internet Programming
UNIT-1 XHTML
Empty elements must also be closed. T'is is )rong. : break. /br0 : 'ori=ontal rule. /'r0 :n image. /img src>*'appy.gif* alt>*Happy face*0 T'is is correct. : break. /br 10 : 'ori=ontal rule. /'r 10 :n image. /img src>*'appy.gif* alt>*Happy face* 10
"
XHTML 0ynta1
More XHTML 0ynta1 /u%es
:ttribute names must be in lo)er case :ttribute alues must be 2uoted :ttribute minimi=ation is for idden T'e XHTML 6T6 defines mandatory elements
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
/table )idt'>*100@*0
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
XHTML Docty"es
78D.-T9P*: Is Mandatory
:n XHTML document consists of t'ree main parts. t'e 6-#T?5E declaration t'e /'ead0 section t'e /body0 section T'e basic document structure is. /A6-#T?5E ...0 /'tml0 /'ead0 /title0... /1title0 /1'ead0 /body0 ... /1body0 /1'tml0 Note# T'e /A6-#T?5E0 declaration refers to a 6ocument Type 6efinition %6T6&. : 6T6 specifies t'e rules for t'e markup language( so t'at t'e bro)sers render t'e content correctly.
,n XHTML *1am"%e
T'e example belo) s'o)s an XHTML document )it' a minimum of reBuired tags. /A6-#T?5E 'tml 5C2L8# *311!"#116T6 XHTML 1.0 Transitional11E,* *'ttp.11))).)".org1T$1x'tml116T61x'tml13transitional.dtd*0 /'tml xmlns>*'ttp.11))).)".org11DDD1x'tml*0 /'ead0 /title0Title of document/1title0 /1'ead0 /body0 /1body0 /1'tml0 Note# T'e xmlns attribute in /'tml0( specifies t'e xml namespace for a document( and is reBuired in XHTML documents.
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
XHTML 1.1
T'is 6T6 is eBual to XHTML 1.0 4trict( but allo)s you to add modules %for example to pro ide ruby support for East3:sian languages&. /A6-#T?5E 'tml 5C2L8# *311!"#116T6 XHTML 1.111E,* *'ttp.11))).)".org1T$1x'tml1116T61x'tml11.dtd*0
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
XHTML 3a%idation
5rogramming )ebI based application can be complex( and XHTML documents must be )ritten correctly to ensure t'at bro)sers process t'em properly. To promote correctly )ritten documents( t'e !"# pro ides a alidation ser ice % alidator.)".org& for c'ecking a documentJs syntax. 6ocument can be alidate by pro iding a C$L t'at specifies t'e file location( by uploading a file to )a%idator$!'$org;fi%e-u"%oad$htm% or y "asting code direct%y into a te1t area$ Cploading a file copies t'e file from t'e userJs computer to anot'er computer on t'e internet. T'is ser ice is called Markup alidation ser ice and it is able to alidate t'e syntax of XHTML documents. :n XHTML document can be alidated )it' !"#Ks alidator.
Headings
4ome text in an XHTML document may be more important t'an ot'er text. XHTML pro ides six 'eadings( called 'eading elements for specifying t'e relati e importance of information. Heading starts from '1 and up to 'H. '1 is most significant 'eading and )it' largest font si=e.
Internet Programming
UNIT-1 XHTML
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
Lin<ing
-ne of t'e most important XHTML features is t'e 'yperlink( )'ic' references ot'er resources( suc' as XHTML documents and images. !'en a user clicks a 'yperlink( t'e bro)ser tries to execute an action associated )it' it. 8n XHTML( bot' text and 8mages can act as a 'yperlink. !eb bro)ser typically underlines text 'yperlinks and colors t'eir text blue by default( so t'at users can distinguis' 'yperlinks from plain text. Links are created using t'e anc'or %a& element. :ttribute 'ref specifies t'e location of linked resource( suc' as a )ebpage( a file or an e3mail address. !'en a C$L does not indicate a specific document on t'e )ebsite( t'e )eb ser er returns a default )eb page. T'is page is often called inde1$htm% or defau%t$htm% 8f t'e )eb ser er cannot locate a reBuested document( it returns an error indication to t'e )eb bro)ser and t'e bro)ser displays a error message to t'e user. Hy"er%in<ing to a !e site /a 'ref>'ttp.11))).google.co.in0 ;oogle/1a0 Hy"er%in<ing to a e-mai% address / 'ref>Omailto.dkpra+apatN0Pgmail.comO0 My E3Mail :ddress /1a0 *1am"%e &#
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
Note# 1. Line 1H31D s'o)s t'e code for creating text 'yperlinks. <. Line <"3<E s'o)s t'e code for creating 8mage Hyperlink. ". Line <H3<L s'o)s t'e code for Hyper linking to an E3Mail :ddress. .ut"ut#
10
Images
Most )eb pages contains bot' text and images. T'e t'ree most important image format used by )eb de eloper are. 4yntax. /img src >Oimage3pat'O )idt'>O100O 'eig't>OE0O0 To use images on )ebpage )e use an img element in t'e document. T'e image fileJs location is specified )it' t'e img elementJs src attribute. ;rap'ical 8nterc'ange format %;8G& Qoint p'otograp'ic Experts ;roup %Q5E;& 5ortable ,et)ork grap'ics %5,;&
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1
11
XHTML
8f t'e image is located in t'e same directory as t'e XHTML document( t'en only image name reBuired( ot'er)ise complete pat' is reBuired. % Line 11=1&& -ptional attribute of image are )idt' and 'eig't. !e can measure image in pixels t'at represent dots of color on t'e screen. E ery image element in an XHTML document must 'a e an alt attribute. 8f a bro)ser cannot render an image( t'e bro)ser displays t'e alt attributeJs alue. T'e alt attribute 'elps you create accessible )eb pages for users )it' documents( especially t'ose )it' ision impairments )'o use text bro)sers. 4peciali=ed soft)are called speec' synt'esi=er can RspeakO t'e alue of alt attribute so t'at a user )it' ision impairment kno)s )'at t'e bro)ser is displaying.
*1am"%e# '
Note# Line 1131< s'o)s t'e code for including images on XHTML document.
.ut"ut.
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
1<
Examples: < > & , < (for lower than) > (for greater than) & (for ampersand) ä (for a umlaut) ö ü Ä Ö Ü € ©
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
1"
Lists
!'en )e are arranging our data or information in a particular seBuence( it is called a list. List may be of t)o types3 -rdered list M #reated using /ol0 element. Cnordered list M #reated using /ul0 element. List 8tem M List index gi en by /li0 element. *1am"%e (# -reating .rdered > Unordered List
.ut"ut#
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML Nested List#
!'en t'ere is a list )it'in a list( it is called a ,ested List. *1am"%e ?#
14
Note# 1. Line D3<" s'o)s code for an ordered list of sub+ects. <. Line 1<3 1H s'o)s code for nested list. .ut"ut#
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
1E
Ta %es
Tables are freBuently used to organi=ed data into ro) and columns. Tables are defined )it' t'e /table0 element as a starting tag. Table element 'as se eral attributes.
7tr: used for indicating table ro). 7td: used for indicating table column.
border M 2order )idt' in pixels . 'eig't and )idt' summary M 6escribes t'e tables contents.
, ta %e has three distinct sections @ head= ody= and foot$ The Head section is defined )it' /t'ead0 element( !'ic' contain 'eader information suc' as column names.
7tr: 3 8ndi idual table ro) 7th: 3 #olumns in t'e 'ead section.
Most bro)ser center text formatted by t' %table 'eader column& element and display t'em in bold. The +ody 0ection or table body contains t'e table primary data. T'e table body is defined in a /tbody0 element.
7tr: 3 4pecifies one table ro) 7td: 3 6ata cell contain indi idual piece of data.
The foot 0ection is defined )it' a /tfoot0 %table foot& element. T'e text placed in t'e footer commonly includes calculation result and footnotes.
7tr: 3 8ndi idual table ro) 7th: 3 #olumns in t'e foot section.
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
*1am"%e A. -rating ta %e
1H
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML Using /o!s"an and -o%s"an
8n a table all t'e data cell are of fixed si=e to fit t'e data t'ey contain. !e can create larger data cell using t'e attributes ro)span and colspan. ro!s"an BC)a%ueC M 9alue s'o)s t'e number of ro)s occupied by a single cell. co%s"an BC)a%ueC M 9alue s'o)s t'e number of columns occupied by a single cell .
1L
.utPut#
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
1N
6orms
!'en bro)sing )ebsites( users often need to pro ide some information from 'is side like searc' key)ords( email address and =ip codes. XHTML pro ides a mec'anism called a form for collecting data from a Cser. 6ata t'at user enter on a )eb page is normally sent to a )eb ser er t'at pro ides access to siteJs resources. Gorm can contain isual and non isual components. 3isua% com"onents include clickable buttons and ot'ers grap'ical user interface components )it' )'ic' user can interact. Non )isua% com"onents( called 'idden inputs store any data t'at you specify. 4uc' as E3mail address and XHTML document filename t'at can act as links.8n XHTML document form is defined by using 7form: element.
7in"ut: element 'as t'ree important attributes M name= ty"e and )a%ue.
name attribute is t'e identification of t'e input element( Qust like ariable name. )a%ue attribute pro ides t'e alue t'at )ill be sent %or posted& to t'e )eb ser er. ty"e attribute specify t'e type of input element. T'ere may be different type of input element. type > 'idden 1 text 1 pass)ord 1 c'eckbox 1 radio 1 submit 1 reset 1 .etc
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
0No$ Ty"e ty"e B EhiddenC Descri"tion :llo)s an aut'or to send form data t'at is not input by a user. Like E3Mail address to )'ic' data )ill be sent( t'e e3 mailJs sub+ect line and a C$L for t'e bro)ser to open after submission ty"e B Ete1t R t'e form. 5ro ide a one line input text box )'ic' :llo)s a user to input
1D
text information like name( e3mail address( comments etc. ty"e BC"ass!ordC T'is input type is used for inputting sensiti e information like
si5e B ENC pass)ord( credit card number )it' maximum si=e of , c'aracters. !it' t'is option input information is masked by using %S& asterisk. T'e actual ty"e B chec< o1 alue input is sent to )eb ser er( not t'e masking c'aracters. T'ese are small sBuare type boxes. #'eckboxes enable users to select one or more from a limited number of option. !'en a user selects a c'eckbox( a c'eckmark appears in t'e c'eckbox( all ot'er c'eckbox remains empty. #'eckboxes can be used indi idually or ty"e B EradioC in group. Eac' c'eckbox used in a group 'as t'e same name. $adio buttons are similar to c'eckbox except t'at t'ey 'a e circular s'ape and allo) t'e user to select only one from t'e limited number ty"e B Efi%eC ty"e B Csu mitC of c'oice. is used for file upload. 6efines a submit button. : 4ubmit button is used to send form data to a ser er. T'e data is sent to t'e page specified in t'e formJs ty"e B EresetC ty"e B EimageC action attribute. 6efines a reset button. : reset button reset all forms fields to t'eir initial alue. 6efines an image as 4ubmit button. T'e src and alt attribute are reBuired )it' t'is.
Internet Programming
UNIT-1 XHTML
<0
alt c'ecked
4TG 4TG
disabled maxlengt'
disabled number name readonly number C$L 2utton c'eckbox file 'idden image pass)ord radio reset submit text alue
4pecifies t'at an input element s'ould be disabled )'en 4TG t'e page loads 4pecifies t'e maximum lengt' %in c'aracters& of an input field %for type>*text* or type>*pass)ord*& 4pecifies a name for an input element 4pecifies t'at an input field s'ould be read3only %for type>*text* or type>*pass)ord*& 4pecifies t'e )idt' of an input field 4pecifies t'e C$L to an image to display as a submit button %only for type>*image*& 4pecifies t'e type of an input element 4TG 4TG 4TG 4TG 4TG 4TG
name
readonly si=e src
type
alue
4TG
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
<1
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
XHTML coding for feedback form
<<
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
,ote. 1. Line 1< M 14 s'o) t'ree inputs of 'idden types. T'ese are set by t'e aut'or of document and 'idden from t'e user. <. Line 1H and <1 s'o)s t'e input of text type. 8t creates a single line text box for input. ". Line 1D s'o)s a multiline text box called textarea for inputting comment from t'e user. 4. Line <" M <L s'o)s c'eckbox type input. E. Line "0 M "" s'o)s radio type input. H. Link "H M 4N s'o) code for dropdo)n list type input.
<"
Interna% Lin<ing
!e 'a e already discussed t'at 'o) to 'yperlink one page to anot'er. ,o) )e study internal linking. 8nternal linking is a mec'anism t'at enables t'e user to +ump bet)een locations in t'e same document. 8nternal linking is useful for long document t'at contain many sections. #licking t'e internal link enables user to find a section )it'out scrolling t'roug' t'e entire document. !e use t'e id attribute for an internal 'yperlinking. Qust like different labels in t'e # 1 #TT programs. 7h1 id B E0tartC: We%come to 0tart7;h1: To crate a link for t'at id )e )ill use an anc'or %/a0& element. Here alue of 'erf attribute )ill be t'e alue of id preceded by pound1'as' %U& sign. 7a href B EF0tartC:0tart7;a:
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi
Internet Programming
UNIT-1 XHTML
<4
Meta *%ement
: searc' engine 'elps us in finding )ebsites. T'ey usually catalog sites by follo)ing links from page to page %T'is process is kno)n as s'i ering or cra)ling& and sa ing identification and information of eac' page. 4earc' engine catalog pages by reading t'e content in eac' pageJs Meta elements( )'ic' specify information about a document. T)o important attribute of meta element are name and content. name M identifies t'e type of meta element. content M pro ides t'e information about t'e document( )'ic' is used by searc' engine for cataloging t'e page.
5repared 2y. 6eepak 7umar 5ra+apat Lecturer. #418T 6epartment 9#ET( 2undi