Search code examples
htmlxhtmlsgml

Why there is no 'include' directive in HTML?


In many programming languages, there is some type of 'include' command/directive/statement which helps developer make the source code, more 'modular' so there is no need to include everything in one single file.

Why there is no such facility in HTML?


Solution

  • Try This Link, May Help You, Import Pages...

    http://www.html5rocks.com/en/tutorials/webcomponents/imports/

    HTML Imports, part of the Web Components cast, is a way to include HTML documents in other HTML documents. You're not limited to markup either. An import can also include CSS, JavaScript, or anything else an .html file can contain. In other words, this makes imports a fantastic tool for loading related HTML/CSS/JS.

    Include an import on your page by declaring a :

    <head>
      <link rel="import" href="/path/to/imports/stuff.html">
    </head>
    

    The URL of an import is called an import location. To load content from another domain, the import location needs to be CORS-enabled:

    <!-- Resources on other origins must be CORS-enabled. -->
    <link rel="import" href="http://example.com/elements.html">