Quantcast
Channel: Envato Tuts+ Web Design
Viewing all articles
Browse latest Browse all 4333

HTML Element: html

$
0
0

The html element is the root of an HTML document. This element is required to create a valid page.

Example

Syntax

1
<!DOCTYPE html>
2
<htmllang="en">
3
<head>
4
<title>My Favorite Foods</title>
5
</head>
6
<body>
7
<h1>My Favorite Foods</h1>
8
<p>Eu non fugiat sunt cupidatat consequat. Dolore nostrud id tempor aute pariatur sit veniam pariatur velit voluptate voluptate excepteur reprehenderit.</p>
9
</body>
10
</html>

Browser Support

The html element is supported in all modern browsers. Read more on caniuse.com.

Attributes

An html element supports Global Attributes in HTML. Global Attributes are common to all HTML elements and can be used on all of them (though they may not have much of an effect on some of them).

Additional attributes:
  • manifest: Specifies the URI of a resource manifest indicating resources that should be cached locally.
  • version: Specifies the version of the HTML Document Type Definition that governs the current document. This attribute is not necessary.
  • xmlns: Specifies the XMLNamespace of the document. The default value is "https://www.w3.org/1999/xhtml"

Don’t Forget the lang Attribute

The HTML lang attribute should always be included on a web page’s <html> element. It’s used to specify the language of text content within the document. This helps search engines deliver search results in the correct language, and helps screen readers switch language profiles for correct accents and pronunciation.

In the syntax example above you’ll see <html lang="en"> which uses the two-letter ISO code for English as the language.

Failing to include the lang attribute on the opening html tag will trigger a warning when validating the document.

screenshot of validation warning when omitting the lang attribute on html elementscreenshot of validation warning when omitting the lang attribute on html elementscreenshot of validation warning when omitting the lang attribute on html element

Content

The html content model is limited and only contains support for the head and body elements.

Did you know? The first version of HTML was written by Tim Berners-Lee in 1993. The widest adoption of the language occurred when HTML was updated to version 4.0.1. Today most modern browsers and websites run the HTML5 specification.

Learn More


Viewing all articles
Browse latest Browse all 4333

Trending Articles