www.webdeveloper.com
Results 1 to 5 of 5

Thread: Including xhtml in xhtml

  1. #1
    Join Date
    Apr 2012
    Posts
    3

    Including xhtml in xhtml

    Hello,

    I'm trying to include an xhtml file in another xhtml file.

    I use this command:
    <!-- #include virtual="includes/Header.shtml" -->

    My header.shtml looks like this:
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
    
    
    
    <head>
    
        <title>Header</title>
    
        <link href="GeneralCSS.css" type="text/css" rel="stylesheet" />
    
    </head>
    
    
    
    <body>
    
        <a href="Index.html">
    
         <img src="images/Logo.jpg" alt="Logo" class="noborder" />
    
        </a>
    
        <hr />
    
    </body>
    
    </html>
    However, this doesn't work. As far as I've figured out, if it'd work the img (called in the header file) and the hr should be displayed in the xhtml file where I include header.shtml?

    Anyone got any tips/suggestions?

  2. #2
    Join Date
    Mar 2011
    Posts
    1,139
    The <!--#include virtual --> instruction will load all of the content from the indicated file into the parent document. You need to structure your documents so that when the parent document and the header.shtml files are combined, there is only one instance of the content from the <!DOCTYPE> to the <body> tag. You can choose either one to hold that content, but not both. Good luck!
    Rick Trethewey
    Rainbo Design

  3. #3
    Join Date
    Apr 2012
    Posts
    3
    Quote Originally Posted by rtrethewey View Post
    The <!--#include virtual --> instruction will load all of the content from the indicated file into the parent document. You need to structure your documents so that when the parent document and the header.shtml files are combined, there is only one instance of the content from the <!DOCTYPE> to the <body> tag. You can choose either one to hold that content, but not both. Good luck!
    Thanks for the reply!

    I deleted everything above the body tag, so my code is:
    Code:
    <body>
        <a href="Index.html">
         <img src="images/Logo.jpg" alt="Logo" class="noborder" />
        </a>
        <hr />
    </body>
    </html>
    But it still doesn't work, I'm sure it's something simple I'm missing here. But I'm just a beginner, I don't see it

  4. #4
    Join Date
    Nov 2002
    Posts
    2,632
    Main HTML
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
        <head>
            <title>Header</title>
            <link href="GeneralCSS.css" type="text/css" rel="stylesheet" />
        </head>
        <body>
            <!-- #include virtual="includes/Header.shtml" -->
        </body>
    </html>
    Include HTML
    Code:
    <a href="Index.html"><img src="images/Logo.jpg" alt="Logo" class="noborder" /></a>
    <hr />
    I would do it more like that.

  5. #5
    Join Date
    Mar 2011
    Posts
    1,139
    It doesn't matter which parts go into the parent document and the header.shtml document as long as you end up with a single, valid HTML document with only one set of start-up tags. Although, on a practical level, you really don't want to use a single common <head> section for all of the pages on your site. Tags like <title> and <meta> description need to be unique to each page.

    In any case, to see what's wrong, load your page in your browser and select View->Source so you can see the resulting HTML document in its entirety. Look for duplicate and missing tags. Good luck!
    Rick Trethewey
    Rainbo Design

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