user656449
user656449

Reputation: 3032

html and body elts around polymer element

What is the reason to put custom element decls insde html, body and head tags?

Like the my-list and my-greeting from https://github.com/PolymerElements/polymer-starter-kit:

<html><head><link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/paper-styles/typography.html">

    </head><body><dom-module id="my-list">
      <template>
        ....
      </template>

      </dom-module>
    <script src="my-list.js"></script>

The following, without html, body and head

    <dom-module id="my-list">
      <template>
        ....
      </template>
      <script>
         .....
      </script>
      </dom-module>

works quite ok. Is there some spec or anything which requires html & body around custom element?

Upvotes: 1

Views: 80

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657466

You can create HTML files which are just elements. Such files don't do anything useful when loaded into the browser. Such element-only files don't need <html><head><body>, just <dom-module>, but they need to be imported in an entry page (usually named index.html) which actually does have <html><head><body> tags.

You can also define elements inline in an entry page directly (in the <body> tag), instead of importing them from another file.

Upvotes: 0

Related Questions