I have previously introduced you to some of the new additions to HTML5, and I believe you all have some understanding of them. Today I will introduce to you the newly added content about HTMLDocument in HTML5. So what are the newly added contents about HTMLDocument in HTML5? The newly added contents about HTMLDocument in HTML5 include readyState attribute, compatibility mode judgment and head attribute. Let me introduce these newly added little things to you one by one.
1. readyState attribute
As early as the IE4 era, the document object introduced the readyState attribute, but it has never been included in the standard. Now, in HTML5 As time goes by, it has been incorporated into the norm. The readyState attribute has two possible values:
(1) loading, the document is being loaded
(2)complete, the document has been loaded
How to use document appropriately What about .readyState? The most appropriate way to use document.readyState is to use it to implement an indicator that the document has been loaded. Until this property is widely supported, implementing such an indicator will still require the onload event handler to set a label indicating that the document has been loaded. The following example is as follows
HTML code
<p>梦龙小站</p> <p class="complete"></p>
JavaScript code
<script type="text/javascript"> window.onload = function(){ var a = 0; var b = 0; if(document.readyState == "complete"){ $(".complete").html( "加载好了" ) } if(document.readyState == "loading"){ $(".load").html( $(".load").html() + "<br/>" + a++ ) } };
Preview effect
2. Compatibility mode judgment
After IE6, it began to distinguish the modes of rendering pages, divided into standard and mixed, and detect the compatibility mode of the page. It becomes a necessary function of the browser. IE adds an attribute called compatMode to the document for this purpose. This attribute is to tell the developer which rendering mode the browser uses. As shown in the small example below, in standard mode, the value of document.compatMode is equal to "CSS1Compat", while in promiscuous mode, the value of document.compatMode is equal to "BackCompat".
JavaScript code
if(document.compatMode == "CSS1Compat"){ alert("标准模式") }else{ alert("混杂兼容模式") }
3. Head attribute
As a supplement to the body element of the document referenced by document.body, HTML5 adds a new document.head attribute, so that the head tag can be referenced. The usage method is as follows
JavaScript code
var head = document.head || document.getElementsByTagName("head")[0];
Make the compatibility as above. If it can be used, use document.head, otherwise still use the getElementsByTagName() method. The browsers supported by the document.head attribute are Chrome and Safari 5.
HTML5 actual combat and analysis of HTMLDocument changes (readyState attribute, compatibility mode and head attribute) are introduced here. Learn some new knowledge in the midst of your busy schedule. Life is still very fulfilling, and put your learning into practice. I would like to share some little things with you, it was such a magical day. Updates related to HTML5 practice and analysis.
【Related recommendations】
1. Free h5 online video tutorial
3. php.cn original html5 video tutorial
4. HTML5 game framework cnGameJS development record-detailed resource loading module code

MicrodatainHTML5enhancesSEOanduserexperiencebyprovidingstructureddatatosearchengines.1)Useitemscope,itemtype,anditempropattributestomarkupcontentlikeproductsorevents.2)TestmicrodatawithtoolslikeGoogle'sStructuredDataTestingTool.3)ConsiderusingJSON-LD

HTML5introducesnewinputtypesthatenhanceuserexperience,simplifydevelopment,andimproveaccessibility.1)automaticallyvalidatesemailformat.2)optimizesformobilewithanumerickeypad.3)andsimplifydateandtimeinputs,reducingtheneedforcustomsolutions.

H5 is HTML5, the fifth version of HTML. HTML5 improves the expressiveness and interactivity of web pages, introduces new features such as semantic tags, multimedia support, offline storage and Canvas drawing, and promotes the development of Web technology.

Accessibility and compliance with network standards are essential to the website. 1) Accessibility ensures that all users have equal access to the website, 2) Network standards follow to improve accessibility and consistency of the website, 3) Accessibility requires the use of semantic HTML, keyboard navigation, color contrast and alternative text, 4) Following these principles is not only a moral and legal requirement, but also amplifying user base.

The H5 tag in HTML is a fifth-level title that is used to tag smaller titles or sub-titles. 1) The H5 tag helps refine content hierarchy and improve readability and SEO. 2) Combined with CSS, you can customize the style to enhance the visual effect. 3) Use H5 tags reasonably to avoid abuse and ensure the logical content structure.

The methods of building a website in HTML5 include: 1. Use semantic tags to define the web page structure, such as, , etc.; 2. Embed multimedia content, use and tags; 3. Apply advanced functions such as form verification and local storage. Through these steps, you can create a modern web page with clear structure and rich features.

A reasonable H5 code structure allows the page to stand out among a lot of content. 1) Use semantic labels such as, etc. to organize content to make the structure clear. 2) Control the rendering effect of pages on different devices through CSS layout such as Flexbox or Grid. 3) Implement responsive design to ensure that the page adapts to different screen sizes.

The main differences between HTML5 (H5) and older versions of HTML include: 1) H5 introduces semantic tags, 2) supports multimedia content, and 3) provides offline storage functions. H5 enhances the functionality and expressiveness of web pages through new tags and APIs, such as and tags, improving user experience and SEO effects, but need to pay attention to compatibility issues.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
