• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 23. Importing External Content > Using Server-Side Includes

Using Server-Side Includes

The easiest way to import external content into a Web page is to use a server-side include. This is not an HTML tag, but a tag that tells the computer that serves your Web pages to the Internet (called a server) to add the referenced file to the page. Although this method's success depends on whether your server understands this tag, almost all servers do these days.

To add a server-side include:

1.
<!--#include virtual="external.html"-->

Add the include tag anywhere in the <body> of your HTML document, and set it to import external.html (Code 23.3).

2.


<!--#echovar="DATE_LOCAL" -->
<!--#echovar="DATE_GMT" -->

Another useful server side tag is the #echo tag in which the server includes either its local time and date or Greenwich Mean Time (GMT) on the page.

3.
external.html

Create a new HTML file, and save it as external.html. This file does not contain the regular <html> open and close tags, which are supplied by the main document—only the <body> tag and any HTML that could be included in a regular HTML document (Code 23.4). The results are shown in Figure 23.3.

Figure 23.3. The server-side include tags allow you to import external content, but only if the page is being delivered from a Web server.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint