Get the App
SLTechnology News&Howtos  ›  Development  › 

How to add new elements to HTML

Shulou Source: shulou.com Published: 2022-06-01 05:03:45 10月03日 Update

In this article, the editor introduces in detail "how to add new elements for HTML", the content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to add new elements to HTML" can help you solve your doubts.

Modern browsers support HTML5.

In addition, all browsers, both old and up-to-date, automatically treat unrecognized elements as inline elements.

Because of this, you can "teach" browsers to deal with "unknown" HTML elements.

Note you can even teach IE6 (WindowsXP2001) browsers to handle unknown HTML elements.

Define a HTML5 element as a block element

HTML5 defines eight new HTML semantic (semantic) elements. All these elements are block-level elements.

To enable older browsers to display these elements correctly, you can set the value of the display property of CSS to block:

Example

Header,section,footer,aside,nav,main,article,figure {

Display:block

}

Add a new element to HTML

You can add new elements to HTML.

This instance adds a new element to HTML and defines a style for the element, which is named:

Example

Add a new element to HTML

Document.createElement ("myHero")

MyHero {

Display:block

Background-color:#ddd

Padding:50px

Font-size:30px

}

My first title

My first paragraph.

My first new element

The JavaScript statement document.createElement ("myHero") adds a new element to the IE browser.

Read here, this article "how to add new elements to HTML" article has been introduced, want to master the knowledge of this article also need to practice and use to understand, if you want to know more about the article, welcome to follow the industry information channel.

Tags: Elements browsers browsing processing examples articles content church proper attributes ideas new knowledge more headings styles steps paragraphs versions knowledge knowledge points Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno macOS Linux Shulou Technology Apple