locked
html xmlns doubt clearing RRS feed

  • Question

  • User-1442981517 posted
    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs"
    Inherits="SiteMaster" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1
    /DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head runat="server">
    <title></title>
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
    </head>
    <body>
    <form runat="server">
    <div class="page">
    <div class="header">
    <div class="title">
    <h1>
    Contoso, Inc.
    </h1>
    </div>
    <div class="clear hideSkiplink">
    <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu"
    EnableViewState="false"
    IncludeStyleBlock="false" Orientation="Horizontal">
    <Items>
    <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
    <asp:MenuItem NavigateUrl="~/Products.aspx" Text="Products"/>
    <asp:MenuItem NavigateUrl="~/Services.aspx" Text="Services"/>
    <asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
    <asp:MenuItem NavigateUrl="~/Contact.aspx" Text="Contact"/>
    </Items>
    </asp:Menu>
     </div>
    </div>
    <div class="main">
    <asp:ContentPlaceHolder ID="MainContent" runat="server"/>
    </div>
    <div class="clear">
    </div>
    </div>
    <div class="footer">
    Copyright <%=DateTime.Now.Year.ToString()%>, Contoso Inc.
    </div>
    </form>
    </body>
    </html>

    the above is a code in which there is a coding as :

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

    my question relates to this one

    i have heard that this is a namespace but then :-

    Q1)  where is it located , is it inside our computer (Server and Client -- which one? ) or in the open internet(in some server)?

    Q2)  Does my computer access this namespace or is it that the master page itself access it when it is "posted"?

    Q3)  what is its use?

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    Tuesday, January 20, 2015 1:58 AM

Answers

  • User1508394307 posted

    xmlns is used to tell to the browser that the document is XHTML and not HTML. "http://www.w3.org/1999/xhtml" is a string which is uniquely identifies the namespace - the URI used does not necessarily reference a real file and browser does not access that file, it's just a name. "http://www.w3.org/1999/xhtml" is a standard namespace that is used by default. Read more about HTML vs XHTML here.

    In other words, first 2 lines started from "<!DOCTYPE" tells to the browser that the document is XHTML 1.0 Strict so that browser should render the document according to that standard. As you can see on the referred page

    XHTML 1.0 Strict
    This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed. The markup must also be written as well-formed XML.

    So if could not use e.g. <frameset> because it is not valid in XHTML.

    In the same time in many cases you might not see the difference between having these 2 lines in your master page or not. It all depends on the content and the way you format your document.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 21, 2015 5:50 AM
  • User61956409 posted

    Hi amigo,

    Thanks for your post.

    The xmlns attribute specifies the xml namespace for a document, and the xmlns attribute is required in XHTML. Besides, you could refer to the following link to get more information about XHTML namespace.

    Hope it will be helpful for you.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 21, 2015 8:22 PM

All replies

  • User1508394307 posted

    xmlns is used to tell to the browser that the document is XHTML and not HTML. "http://www.w3.org/1999/xhtml" is a string which is uniquely identifies the namespace - the URI used does not necessarily reference a real file and browser does not access that file, it's just a name. "http://www.w3.org/1999/xhtml" is a standard namespace that is used by default. Read more about HTML vs XHTML here.

    In other words, first 2 lines started from "<!DOCTYPE" tells to the browser that the document is XHTML 1.0 Strict so that browser should render the document according to that standard. As you can see on the referred page

    XHTML 1.0 Strict
    This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed. The markup must also be written as well-formed XML.

    So if could not use e.g. <frameset> because it is not valid in XHTML.

    In the same time in many cases you might not see the difference between having these 2 lines in your master page or not. It all depends on the content and the way you format your document.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 21, 2015 5:50 AM
  • User61956409 posted

    Hi amigo,

    Thanks for your post.

    The xmlns attribute specifies the xml namespace for a document, and the xmlns attribute is required in XHTML. Besides, you could refer to the following link to get more information about XHTML namespace.

    Hope it will be helpful for you.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 21, 2015 8:22 PM