HTML - tags - h...

revision:


Content

"h1" to "h6" tags : define HTML tags "head" tag : a container for metadata, between "html" and "body" tag "header" tag : a container for introduction and/or navigation "hr" tag : defines a break in a page "html" tag : a container for all elements in HTML document


"h1" to "h6" tags : define HTML tags

top

The <h1> to <h6> tags define HTML headings : <h1> defines the most important heading and <h6> defines the least important heading.
Only use one <h1> per page - this should represent the main heading/subject for the whole page. Also, do not skip heading levels - start with <h1>, then use <h2>, and so on.

Search engines use the headings to index the structure and content of your web pages. Users often skim a page by its headings. It is important to use headings to show the document structure. Use HTML headings for headings only. Don't use headings to make text BIG or bold.

Each HTML heading has a default size. However, you can specify the size for any heading with the "style" attribute, using the CSS "font-size" property.

Attributes: these elements include the global attributes.

Syntax :
            <h1> . . . </h1>
            <h2> . . . </h2>
            <h3> . . . </h3>
            <h4> . . . </h4>
            <h5> . . . </h5>
            <h6> . . . </h6>
        

some examples

example
`

This is heading 1

This is heading 2

This is heading 3

This is heading 4

This is heading 5
This is heading 6
code:
                <h1 class="spec">This is heading 1</h1>
                <h2 class="spec">This is heading 2</h2>
                <h3 class="spec">This is heading 3</h3>
                <h4 class="spec">This is heading 4</h4>
                <h5 class="spec">This is heading 5</h5>
                <h6 class="spec">This is heading 6</h6>
            

example

This is heading 1

This is heading 2

This is heading 3

This is heading 4

code:
                <h1 class="spec" style="text-align:center">This is heading 1</h1>
                <h2 class="spec" style="text-align:left">This is heading 2</h2>
                <h3 style="text-align:right">This is heading 3</h3>
                <h4 style="text-align:justify">This is heading 4</h4>
            

"head" tag : a container for metadata, between "html" and "body" tag

top

The <head> element is a container for metadata (data about data) and is placed between the <html> tag and the <body> tag. Metadata is data about the HTML document and is not displayed. Metadata typically define the document title, character set, styles, scripts, and other meta information.

The following elements can go inside the <head> element:

the <title> tag defines the title of a web page (required). The tag is metadata representing the title of the entire HTML content and not its content.

the <style> tag contains CSS code that defines how HTML elements should be rendered in a browser.

the <base> tag defines an absolute (base) URL for all relative URLs.

the <link> tag defines the relationship between the current HTML document and the resource to which it refers, or contains a link to an external style sheet. It can have two attributes: rel="stylesheet" and href.

the <meta> tag provides additional information (metadata) about HTML document. The "head" of a page can include different kinds of "meta' elements that may contain name and content attributes.

the <script> tagcontains a script (generally JavaScript), or reference to an external file with scripts.This element may not be included in "head". Sometimes, it is better to put it at the bottom of the "body. The <script> element may seem empty, but it's not.

the <noscript> tag defines an alternate text, which is displayed, if the browser doesn't support scripts or scripts are disabled by the user.

Attributes: the <head> element supports the global attributes.

Syntax : <head> . . . </head>

some examples

example

Codes:

                    <html>
                        <head>
                        <link rel="stylesheet" href="styles.css">
                        </head>
                        <body>
                            <h1>Hello World!</h1>
                            <h2>I am formatted with a linked style sheet.</h2>
                            <p>Me too!</p>
                </body>
                </html>
                

example

Codes:

                    <html>
                        <head>
                        <title>Title of the document
                        <style>
                            body{background-color: #d3d3d3;}
                            p{color:  #1c87c9;}
                            a{color: red;}
                        </style>
                        </head>
                        <body>
                        <p>Paragraph</p>
                        <a href="#">Link</a>
                        </body>
                    </html>
                

"header" tag : a container for introduction and/or navigation

top

The <header> element represents a container for introductory content or a set of navigational links. It typically contains: one or more heading elements (<h1> - <h6>), logo or icon, authorship information.

You can have several <header> elements in one HTML document. However, <header> cannot be placed within a <footer>, <address> or another <header> element.

The <header> element is one of several semantic document tags introduced with HTML5. It is used to define a header section for the element that contains it. It can be used as a header for a whole page (the most common usage), but can also be used as the header for an article or any other piece of on-page content.

A <header> is always related to the element that contains it (so no element should directly contain two "header" elements).

Attributes: the <header> element supports the global attributes and event attributes.

Syntax : <header > . . . </header>

some examples

example
   

A heading here

Posted by John Doe

Some additional information here

Lorem Ipsum dolor set amet....

Codes:

                    <div class="spec">
                        <article>
                            <header>
                               <h1>A heading here</h1>
                            <p class="spec">Posted by John Doe</p>
                            <p class="spec">Some additional information here</p>
                            </header>
                            <p class="spec">Lorem Ipsum dolor set amet....</p>
                        </article>
                    </div>
                

example

Codes:

                    <div class="spec">
                        <header> 
                            <a style="margin-left: 4vw;" src="/" id="logo">Site Title</a> 
                            <nav> 
                                <ul style="margin-left: 4vw;"> 
                                    <li><a href="/">Home</a></li> 
                                    <li><a href="/about">About</a></li> 
                                    <li><a href="/contact">Contact</a></li>
                                </ul>
                            </nav>
                        </header>
                    </div>
                

"hr" tag : defines a break in a page

top

The <hr> tag defines a thematic break in an HTML page (e.g. a shift of topic). It is most often displayed as a horizontal rule that is used to separate content (or define a change) in an HTML page.

Attributes: the <hr> element supports the global attributes and event attributes.

Syntax : <hr>

some examples

example

HTML is the standard markup language for creating Web pages. HTML describes the structure of a Web page, and consists of a series of elements. HTML elements tell the browser how to display the content.


CSS is a language that describes how HTML elements are to be displayed on screen, paper, or in other media. CSS saves a lot of work, because it can control the layout of multiple web pages all at once.


JavaScript is the programming language of HTML and the Web. JavaScript can change HTML content and attribute values. JavaScript can change CSS. JavaScript can hide and show HTML elements, and more.

Codes:

                <p class="spec">HTML is the standard markup language for creating Web pages. 
                HTML describes the structure of a Web page, and consists of a series of elements. 
                HTML elements tell the browser how to display the content.</p>
                    <hr>
                <p class="spec">CSS is a language that describes how HTML elements are to be displayed on 
                    screen, paper, or in other media. CSS saves a lot of work, because it can control the layout 
                    of multiple web pages all at once.</p>
                <hr>
                <p class="spec">JavaScript is the programming language of HTML and the Web. 
                JavaScript can change HTML content and attribute values. JavaScript can change CSS. 
                JavaScript can hide and show HTML elements, and more.</p>
                

example

This is some text. This is some text. This is some text.


This is some text. This is some text. This is some text.

Codes:

                    <p class="spec">This is some text. This is some text. This is some text.</p>
                    <hr style="margin-left:5vw; width:50%;text-align:left;">
                    <p class="spec">This is some text. This is some text. This is some text.</p>
                

"html" tag : a container for all elements in HTML document

top

The <html> tag represents the root of an HTML document. The tag is the container for all other HTML elements (except for the <!DOCTYPE> tag). You should always include the "lang" attribute inside the <html> tag, to declare the language of the Web page. This is meant to assist search engines and browsers. Before the <html> tag we can only use <Doctype> declaration, which gives information about the HTML version to the browser.

Attributes: the <html> element supports the global attributes.

Syntax : <html> . . . </html>

some examples

example

Codes:

                    <html lang="en">
                        <head>
                        <title>Title of the document</title>
                        </head>
                        <body>
                        <h1>This is a heading</h1>
                        <p>This is a paragraph.</p>
                        </body>
                    </html>
                

example

Codes:

                    <!DOCTYPE html>  
                    <html>  
                    <head>  
                        <title>HTML tag</title>  
                    </head>  
                    <body>  
                        <h2>Example of HTML tag</h2>  
                        <p> Write your main Content within Body of the HTML document. </p>  
                    </body>  
                    </html>