dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: xmlns attribute

  1. #1
    Join Date
    Jan 2011
    Posts
    42

    xmlns attribute

    I just changed all of my pages to xhtml 1.0 strict. When I put my site through the w3 validator I got the following message:

    Missing xmlns attribute for element html. The value should be: http://www.w3.org/1999/xhtml

    <head>

    Many Document Types based on XML need a mandatory xmlns attribute on the root element. For example, the root element for XHTML might look like:
    <html xmlns="http://www.w3.org/1999/xhtml">


    I don't know much about this xmlns attribute. Do I need to add this to all of my pages below my doctype. I was about to do this, but then I read the following on w3schools site:

    the HTML validator at w3.org does not complain when the xmlns attribute is missing in an XHTML document. This is because the namespace "xmlns=http://www.w3.org/1999/xhtml" is default, and will be added to the <html> tag even if you do not include it.

    So does that mean I don't need to add the xmlns attribute? If so, why did the validator give me that message?

    Also, if I do add it should I just do this one?:

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

    or this one?:

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

  2. #2
    Join Date
    Jan 2011
    Posts
    42

    here's my code

    These are my first few lines as they currently are:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="Expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="Pragma" content="no-cache" />

    <link rel="shortcut icon" href="/favicon.ico" />

    I got these errors from the validator:

    Line 4, Column 6: document type does not allow element "head" here; assuming missing "html" start-tag
    <head>

    Missing xmlns attribute for element html. The value should be: http://www.w3.org/1999/xhtml
    <head>

    Many Document Types based on XML need a mandatory xmlns attribute on the root element. For example, the root element for XHTML might look like:
    <html xmlns="http://www.w3.org/1999/xhtml">

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles