Title: XHTML template Valid code
1XHTML templateValid code
2Writing valid code
- Valid XHTML requires
- Doctype
- Character encoding
- We need to add these to the template
3Doctypes
lt!DOCTYPE HTML PUBLIC "-//W3C// DTD HTML 4.01
Transitional//EN" http//www.w3.org/TR/html4/loos
e.dtdgt
HTML 4.01
lt!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN "http//www.w3.org/TR/xhtml1/DTD/xhtm
l1-strict.dtd"gt
XHTML 1.0
4About DTDs
From W3C
- DOCTYPE declarations are required in conforming
HTML or XHTML documents - When the document is validated, the validator
uses the information in the declaration to
compare against the DTD and report any warnings
or errors - DOCTYPE declarations are SGML syntax that should
be at the top of every HTML or XHTML document you
author - they define the document type and provide a URI
to the documents DTD (Document Type Definition) -
5Doctypes
lt!DOCTYPE HTML PUBLIC "-//W3C// DTD HTML 4.01
Transitional//EN" http//www.w3.org/TR/html4/loos
e.dtdgt
- lt!DOCTYPEgt
- Declaring the doctype puts the browser in
standards mode- so that standard compliant code
can be used - The doctype declaration tells validators how to
judge the code in order to check the syntax.
HTML 4.01
lt!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN "http//www.w3.org/TR/xhtml1/DTD/xhtm
l1-strict.dtd"gt
XHTML 1.0
6DTD Flavours
- The Strict DTD includes all elements and
attributes that have not been deprecated or do
not appear in frameset documents. - The Transitional DTD includes everything in the
strict DTD plus deprecated elements and
attributes (most of which concern visual
presentation). - The Frameset DTD includes everything in the
transitional DTD plus frames as well.
http//www.w3.org/TR/html4/struct/global.html
7Insert a doctypes
- Never type a doctype !
- Always cut and paste from the W3C site
- Find the link to Doctype page in the website
(http//www.w3.org/QA/2002/04/valid-dtd-list.html)
- Find the XHTML strict doctype (in template at top
of page) - Cut and paste into your notepad doc
http//learnline.cdu.edu.au/units/hit151/basics/xh
tmltemplates.html
8Structure
Strict Doctype Declaration Information about code
used
lthtml xmlnshttp//www.w3.org/1999/xhtml xml
langen langengt ltheadgt lttitlegt First HTML
examplelt/titlegt lt/headgt ltbodygt lth1gt welcome to
the world of HTMLlt/h1gt lthrgt ltpgtHTML
ltstronggtreallylt/stronggt isnt so
hard!lt/pgt ltpgtWhat can be challenging is learning
to write the code in such a way that it
ltemgt does what you want it to.lt/emgtlt/pgt lt/bodygt lt/
htmlgt
lt!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN" "http//www.w3.org/TR/xhtml1/DTD/xhtm
l1-strict.dtd"gt
HTML element with its namespace attribute
Head Information about the document
Body Actual contents of the document
HTML element
9Character encoding
lt!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" http//www.w3.org/TR/xhtml1/ tr
ansitional.dtdgt lthtml xmlnshttp//www.w3c.org
/1999/xhtmlgt ltheadgt lttitlegt First HTML
examplelt/titlegt ltmeta http-equivcontent-type
contents text/html charsetutf-8
/gt lt/headgt lt/htmlgt
Doctype Declaration Information about code used
HTML element
Head Information about the document
Body Actual contents of the document