#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Sydney, NSW, Australia
    Posts
    40
    Rep Power
    14

    Xhtml - <html xmlns=...> question.


    Hi,

    I am updating my HTML to the xhtml 1.0 specification to make any updates later involving XML easier. At the moment my <html> tag looks like:

    <html xml:lang="en" lang="en">

    But I see that some people add the following:

    <html xmlns="http://www.w3.org/1999/xhtml">

    Is it needed, and what does it do? I want to keep everything to specification and know what everything in the file does. Thanks for your help!
    Cheers,
    Michael Bray
  2. #2
  3. No Profile Picture
    CF sMod
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Maine, USA (a.k.a. Boonies)
    Posts
    242
    Rep Power
    14
    It declares the main namespace. If you were to save your document as .xml instead of .html, and expected it to render as XHTML, you would need the xmlns="bla" declaration inside the root element.
    Jason Contact Me
    Super moderator @ CodingForums
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2001
    Location
    USA
    Posts
    830
    Rep Power
    14
    Slight clarification of what jkd explained: regardless of what extension you save the file with, to be an XHTML conforming document the xmlns attribute must be "present" with that value. Actually, the attribute is declared with a fixed value in the DTD, so if you don't specify it in your document it will still be valid. If you do specify it, it must have that value. See XHTML 1.0: The Extensible HyperText Markup Language: 3.1.1 Strictly Conforming Documents.

IMN logo majestic logo threadwatch logo seochat tools logo