This page is Not Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.



Represents a user-defined HTML tag (nonstandard)

Overview Table

DOM Interface


This example uses the custom element to create custom RED, GREEN, and BLUE elements. These elements change the color of the text to red, green, or blue, depending on whether it is surrounded by RED, GREEN, or BLUE tags. In this example, the RED, GREEN, and BLUE tags are defined within a namespace called CUSTOMTAG.

@media all {
    CUSTOMTAG\:RED { color: red; }
    CUSTOMTAG\:GREEN { color: green; }
    CUSTOMTAG\:BLUE { color: blue; }
This text is red because it is enclosed within opening
and closing CUSTOMTAG:RED tags.
This text is green because it is enclosed within opening
and closing CUSTOMTAG:GREEN tags.
This text is blue because it is enclosed within opening
and closing CUSTOMTAG:BLUE tags.

View live example



To declare a namespace, use the XMLNS attribute of the HTML element. When defining custom tags, you must enclose custom tag definitions within an @media wrapper. Custom tags become much more interesting when applied with a Dynamic HTML (DHTML) behavior. Dynamic HTML (DHTML) behaviors (or behaviors) and styles are applied to elements on a page the same way—using Cascading Style Sheets (CSS) attributes. More specifically, the proposed CSS behavior attribute enables a document author to specify the location of the behavior and apply that behavior to an element. The Windows Internet Explorer support for custom tags on an HTML page requires that a namespace be defined for the tag. Otherwise, the custom tag is treated as an unknown tag when the document is parsed. Although navigating to a page with an unknown tag in Internet Explorer does not result in an error, unknown tags have the disadvantage of not being able to contain other tags, nor can they have behaviors applied to them. This element is available in HTML and script as of Microsoft Internet Explorer 5.

See also

Related pages

  • Using Custom Tags in Internet Explorer