4008-20056277    
20056277@qualidyne.com.cn
Menu
What are you looking for?

HTML Document Structure Before And After HTML5 Heres What C

Source:adminAuthor:admin Addtime:2021/10/04 Click:

HTML Guide To Building Web Forms Novice Developers Should Keep This Close To Hand

Lists Bring Order To Web Pages: Heres The HTML Code To Create Them

Embedding Modern Media With HTML5: Get The Code & Instructions To Succeed

Web Images: Best Practices and HTML Code In One Useful Guide

8 Invalid HTML Elements You Should Stop Using Immediately

Javascript: The Beginners Guide To Understanding Modern Javascript

What On Earth Is Semantic Markup? (And Why Should You Learn To Write It)

HTML Tables: Find Out When To Use Them (And When To Avoid)

Barbaric Data Center Downtime Costs Exposed!

The 7 Most Hated Internet Innovations of All Time

10 Completely Innocent Websites Britain Blocked (And How It Happened)

7 Free Wifi Safety Steps And How To Implement Them [Infographic]

What Is Doxing? (And Why Is It So Scary?): An Infographic

The Student Web Developers Ultimate Resource Centre 10 Articles You Need In 2019

HTML Guide To Building Web Forms Novice Developers Should Keep This Close To Hand

Lists Bring Order To Web Pages: Heres The HTML Code To Create Them

Embedding Modern Media With HTML5: Get The Code & Instructions To Succeed

Web Images: Best Practices and HTML Code In One Useful Guide

8 Invalid HTML Elements You Should Stop Using Immediately

Javascript: The Beginners Guide To Understanding Modern Javascript

What On Earth Is Semantic Markup? (And Why Should You Learn To Write It)

HTML Tables: Find Out When To Use Them (And When To Avoid)

Barbaric Data Center Downtime Costs Exposed!

The 7 Most Hated Internet Innovations of All Time

10 Completely Innocent Websites Britain Blocked (And How It Happened)

7 Free Wifi Safety Steps And How To Implement Them [Infographic]

What Is Doxing? (And Why Is It So Scary?): An Infographic

The Student Web Developers Ultimate Resource Centre 10 Articles You Need In 2019

HTML/HTML Document Structure Before And After HTML5 Heres What Changed

HTML Document Structure Before And After HTML5 Heres What Changed

Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page.Learn more

If you want to write semantic markup and believe us,you do want to write semantic markup then you need to structure HTML documents properly. Thehtml,head, andbodyelements have been part of the HTML specification since the mid 1990s, and up until a few years ago they were the primary elements used to give structure to HTML documents. However, the situation has changed dramatically in the last few years as HTML5 has added a slew of new tags that can be used to add rich semantic meaning to the structure of an HTML document.

If youve been using HTML for any time at all you know that every bit of HTML needs to be wrapped inhtmltags. An openinghtmltag should appear first and a closing/htmltag should appear at the bottom of the document. Every other bit of HTML should appear between those two tags.

Theheadelement is the first element to appear after the openinghtmltag. In the documentheadwe place things like the pagetitleandmetadata, we add JavaScript to our page with thescripttag, and we [link] to external stylesheets and other resources.

On most webpages theheadelement is a very busy place. For this reason,weve created a tutorialthat explains the tags that typically appear in theheadelement and what these tags are used for.

All of the content that is visible on a web page is nested between opening and closingbodytags. The body is the primary container of the content that makes up a web page.

Up until HTML5, that was pretty much it for basic HTML document structure. All of our code was dropped in between thebodytags and styled withCSS. However, now that HTML5 has broad support among modern browsers, its time to implement the new HTML5 tags that will give our HTML documents a much more meaningful structure.

In this brief tutorial well touch on all of the new tags added as part of HTML5 to define the structure and content of a web page. The elements were going to cover in this guide include:

Using these elements isnt as complicated as it might appear at first glance, and most are fairly self-explanatory. Well make a quick pass over each new element, and then draw up an HTML template you can use these new tags to add rich semantic meaning to your markup.

Theheaderelement is used to contain the content that appears at the top of every page of your website: the logo, tagline, search prompt, and possibly a navigational menu. In most cases, theheaderelement is best positioned as a direct descendant of thebodyelement, but its also ok to place it inside themainelement if you prefer.

Use themainelement betweenheaderandfooterelements to contain the primary content of your web page. Themainelementcannot be a descendantof anarticle,aside,header,footer, ornavelement. Instead, it should be a direct descendant of thebodyelement. Think of it as the direct replacement for thediv id=mainyouve used in the past to wrap up your entire page contents.

Its also ok to use more than onemainelement on a webpage. For example, ifyour bloghomepage includes your five most recent posts, it would be appropriate to wrap each post in its ownmainelement or you could wrap each inarticletags.

Navigational menus are commonly placed at the top of a web page, in a sidebar, or in the page footer. Wherever you happen to place a navigational menu, wrap it innavtags. Note that you dont need to usenavtags for every link, just for blocks of links that provide either sitewide navigation or navigation for a specific part of a website.

If your website includes blog posts, articles, or any other content that could just as well appear on another website as syndicated content, wrap that content in anarticlepost. You can use anarticleelement just about anywhere other than nested within anaddresselement, but in most cases anarticleelement will be a direct descendant of amainelement or of asectionelement that is a direct descendant of amainelement.

Thesectionelement is used to identify content that is a major sub-section of a larger whole. For example, if youve posted a long-form ebook in HTML format, it would be reasonable to wrap each chapter in asectionelement. Likewise, if you have a sidebar (semantically wrapped inasidetags) that contains four sections ads, a search prompt, related posts, and a newsletter signup form it would be ok to wrap each of these four sections insectiontags since a written outline of the sidebar contents would include a line item for each of the four sections.

There is some confusionabout when to use asectionand when to use adiv. Heres a good rule of thumb to help you know when to use each:

if youre wrapping up some content purely to make it easier to style the content or to make it easier for some JavaScript to get ahold of it.

if you would list the content as an item when writing out an outline of the document.

If your website contains information that isnt directly related to the main content of the page, it would be appropriate to wrap that information inasidetags. For example, if you write a post that includes some technical terms, and you add definitions for those terms in a sidebar, it would make sense to wrap those definitions inasidetags. It is also common for the entire sidebar of a blog-type website to be wrapped inasidetags to make it clear that the sidebar is not part of the primary content of the page.

Theaddresselement provides contact information for the nearest parentarticleorbodyelement that contains it. Use theaddresselement inside anarticleto provide contact information for the articles author. Use it outside of anarticlein themainorfooterelements, or as a direct descendant of thebodyelement, to provide contact information for the websites owner.

Thefooterappears at the bottom of a section of a document. Typically, thefooteris a direct descendant of thebodyelement, but it can also be used within amainelement, asection, or anarticle. The most common use of thefooterelement is to place it at the bottom of an HTML document to contain things like a copyright notice, links to related content,addressinformation about the owner of the website, and links to administrative things like privacy policies and websites terms of service.

You may also use thefooterelement within anarticleto provide metadata about that particular article. For example, ifarticletags have been used to wrap a forum post, it would be appropriate to wrap copyright information and the date and time the post was made in afooterelement and place it at the bottom of thearticle.

The template below will show you how all of these elements are properly nested together. We invite you to copy it and use it as a boilerplate template for all of your HTML documents.

html !--Only the head and body elements are supposed to be direct descendants of the html element. All others should be descendants of either the head or body-- head !--The head element must be a direct descendant of the html element-- !--The head element is a very busy place for most websites, so weve created a tutorial to walk you through the different elements and tasks accomplished in the head element. You can find it at the following address: -- titleYour Webpage Title Goes Here/title /head body !--The body element contains the full visible content of the web page-- header !--The header typically includes your logo, tagline, and may contain a nav element-- nav !--The nav element isnt used for every single link but for navigational menus-- /nav /header main !--The main element cannot be used inside of anything other than the body element. It is intended to hold the main content of the page.-- nav !--You can use a nav element just about anywhere-- /nav article !--If your web page contains a blog post or news article it makes sense to wrap the whole article in article tags-- aside !--The aside tag can be used within an article or outside of it. It is used to mark content that is related but not central to the main content of the page-- /aside section !--Sections are used to seperate major parts of an element, such as chapters of an HTML ebook, or to cordone off the comments section from the rest of the main element-- /section address !--An address element inside of an article element is used to provide contact info for the author of the article-- /address /article aside !--The aside element would also be used to mark a sidebar if used outside of the main element-- section !--Within a sidebar you could use section elements to identify the different parts of the sidebar. For example, you could put adds in one section, related posts in a second section, and a newsletter signup form in a third section element.-- /section /aside /main footer !--The footer typically contains links to things like About Us, Privacy Policy, Contact Us and so forth. It may also contain a nav, address, section, or aside element.-- address !--Put an address element in the footer and youre indicating that the contact info within the element is for the owner of the website rather than the author of the article.-- /address /footer /body /html

Jon is a freelance writer, travel enthusiast, husband and father. He writes about web technologies such as WordPress, HTML, and CSS.

The main element is used to denote the content of a webpage that relates to the central topic of that page or application. It should include content that is unique to that page and should not include content that is duplicated across multiple webpages, such as headers, footers, and primary navigation elements.

The header element is used to identify content that precedes the primary content of the web page and often contains website branding, navigation elements, search forms, and similar content that is duplicated across all or most pages of a website.

The footer element is a structural element used to identify the footer of a page, document, article, or section. A footer typically contains copyright and authorship information or navigational elements pertaining to the contents of the parent element.

The aside element is used to identify content that is related to the primary content of the webpage, but does not constitute the primary content of the page. Author information, related links, related content, and advertisements are exampes of content that may be found in an aside element.

The article element identifies a self-contained piece of content which could theoretically be distributed to other websites and platforms as a stand-alone unit. The article element is a good choice to contain entire blog posts, news articles, and similar content.

The title element is a required HTML element used to assign a title to an HTML document. Page titles are not displayed in the browser window, but they are used as the page name by search engines and displayed by browsers in the title bar, on the page tab, and as the page name of bookmarked webpages.

The isindex element was used to create a single line search prompt for querying the contents of the document. Implementation of the element was inconsistent and the functionality duplicated by the form and input elements. As a result, isindex was deprecated in HTML 4.01.metacontent

The meta element is used to add machine-readable information to an HTML document. Information added with the meta tag is not displayed to website visitors but is provided for use by browsers and web crawlers.html commentThis element is used to add a comment to an HTML document. An HTML comment begins with code!/code and the comment closes with code/code. HTML comments are visible to anyone that views the page source code, but are not rendered when the HTML document is rendered by a browser.DOCTYPEThe !DOCTYPE html declaration is used to inform a website visitors browser that the document being rendered is an HTML document. While not actually an HTML element itself, every HTML document should being with a DOCTYPE declaration to be compliant with HTML standards.basetarget

The base element is used to identify a base URL upon which to build all relative URLs that appear on a webpage. In addition, if the base element has a target attribute, the target attribute will be used as the default attribute for all hyperlinks appearing in the document.bodybackground

The body element contains the entire content of a webpage. It must be the second element inside of the parent html element, following only the head element.htmlThe html element is used as a container for all of the HTML of an entire document.headThe head element contains information about an HTML document that is used by browsers and web crawlers but is not displayed to website visitors.divalign

The div element defines an arbitrary block of content which can be placed and styled as a single unit.Tutorials and ResourcesWhat Is Metadata In HTML Documents?: Head Elements Explained

Input Pattern: Use It To Add Basic Data Validation In HTML5

HTML Tags Guide To Adding Images To Your Web Documents

The HTML Comment Tag: Heres How To Use It In Your Code

How To Use The a To Make Links & Open Them Where You Want!

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.