SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is this a decent beginning for standardized code?

    I've been trying to do a little research. I mostly concerned with making sure my code is standards compliant and works in as many browsers as possible. Is this a decent way to start my webpages?

    Code:
    <!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "TR/xhtml1/DTD/xhtml1-strict.dtd" />
    <html xmlns="/1999/xhtml" lang="en">
    <head>
    	<meta name="description" content="Description of the website" />
    	<meta name="keywords" content="KeyWords, Keywords, keywords, keywords" />
    	<meta name="author" content="Authors Name" />
    	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    	
    	<title>Title of the Website</title>
    
    	<link ref="stylesheet" type="text/css" href="main.css" />
    
    </head>
    <body>
    I took the out the urls because the forum wouldn't let me post links

  2. #2
    Non-Member thewebhostingdir's Avatar
    Join Date
    Oct 2005
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, your above code is XHTML complaint and would work on all browsers properly.

  3. #3
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The xmlns attribute in the HTML element and the URI in the doctype look unusual. Why aren't they full URIs, including the W3 domain name?

  4. #4
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by thewebhostingdir View Post
    yes, your above code is XHTML complaint and would work on all browsers properly.
    I am worried that you think that, the code in the example does not validate on a number of levels.

  5. #5
    SitePoint Wizard bronze trophy Black Max's Avatar
    Join Date
    Apr 2007
    Posts
    4,029
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    From the w3 validator:

    No DOCTYPE found!

    # Line 1, Column 3: unknown declaration type "doctype"
    # Error Line 2, Column 25: value of fixed attribute "xmlns" not equal to default
    # Error Line 2, Column 1: Wrong xmlns attribute for element html. The value should be: http://www.w3.org/1999/xhtml
    # Error Line 11, Column 12: Attribute "ref" is not a valid attribute. Did you mean "nohref" or "href"?
    # Error Line 14, Column 7: end tag for "body" omitted, but OMITTAG NO was specified
    # Error Line 14, Column 7: end tag for "html" omitted, but OMITTAG NO was specified
    # Info Line 2: start tag was here
    # Error Line 1, Column 1: XML Parsing Error: StartTag: invalid element name
    # Error Line 1, Column 1: XML Parsing Error: Extra content at the end of the document
    I, too, am startled that someone would consider this standards-compliant.

  6. #6
    SitePoint Wizard bronze trophy Black Max's Avatar
    Join Date
    Apr 2007
    Posts
    4,029
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Here's a basic template that I often use. The content in the style sheet and in the body is just there to give the validator something to chew on.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">

    <html lang="en">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

    <title></title>

    <style type="text/css">

    body {
    width: 100%;
    }

    </style>

    </head>

    <body>

    <p>bleah</p>

    </body>
    </html>
    Nothing wrong with changing the charset to UTF-8, for example.

    Question: Every time I use this template, I get a site that validates 100% with HTML Tidy, but generates 1 warning in the w3 validator. But the damn validator won't tell me what the warning is for!! Can anyone tell me what it is?


Bookmarks

Posting Permissions

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