All html body tags

HTML Elements

An HTML element is defined by a start tag, some content, and an end tag.

HTML Elements

The HTML element is everything from the start tag to the end tag:

Examples of some HTML elements:

Note: Some HTML elements have no content (like the
element). These elements are called empty elements. Empty elements do not have an end tag!

Nested HTML Elements

HTML elements can be nested (this means that elements can contain other elements).

All HTML documents consist of nested HTML elements.

The following example contains four HTML elements ( , , and

):

Example

My First Heading

My first paragraph.

Example Explained

The element is the root element and it defines the whole HTML document.

It has a start tag and an end tag .

Then, inside the element there is a element:

My First Heading

My first paragraph.

The element defines the document’s body.

It has a start tag and an end tag .

Then, inside the element there are two other elements: and

:

My First Heading

My first paragraph.

The element defines a heading.

It has a start tag

and an end tag

:

My First Heading

The

element defines a paragraph.

It has a start tag

and an end tag

:

Never Skip the End Tag

Some HTML elements will display correctly, even if you forget the end tag:

Example

This is a paragraph

This is a paragraph

However, never rely on this! Unexpected results and errors may occur if you forget the end tag!

Empty HTML Elements

HTML elements with no content are called empty elements.

The
tag defines a line break, and is an empty element without a closing tag:

Example

This is a
paragraph with a line break.

HTML is Not Case Sensitive

HTML tags are not case sensitive: means the same as

.

The HTML standard does not require lowercase tags, but W3C recommends lowercase in HTML, and demands lowercase for stricter document types like XHTML.

At W3Schools we always use lowercase tag names.

Читайте также:  text-transform

HTML Tag Reference

W3Schools’ tag reference contains additional information about these tags and their attributes.

Tag Description
Defines the root of an HTML document
Defines the document’s body
to Defines HTML headings

For a complete list of all available HTML tags, visit our HTML Tag Reference.

Источник

This is a heading

This is a paragraph.

The element contains all the contents of an HTML document, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.

Note: There can only be one element in an HTML document.

Browser Support

Global Attributes

Event Attributes

More Examples

Example

Add a background image to a document (with CSS):

Hello world!

Visit W3Schools.com!

Example

Set the background color of a document (with CSS):

Hello world!

Visit W3Schools.com!

Example

Set the color of text in a document (with CSS):

Hello world!

This is some text.

Visit W3Schools.com!

Example

Set the color of unvisited links in a document (with CSS):

Example

Set the color of active links in a document (with CSS):

Example

Set the color of visited links in a document (with CSS):

Default CSS Settings

Most browsers will display the element with the following default values:

Example

body <
display: block;
margin: 8px;
>

Unlock Full Access 50% off

COLOR PICKER

colorpicker

Join our Bootcamp!

Report Error

If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:

Thank You For Helping Us!

Your message has been sent to W3Schools.

Top Tutorials
Top References
Top Examples
Get Certified

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Источник

HTML Tag

The tag defines a web page content (text, images, links, etc.). It is placed inside the element, after the element. In an HTML document, we can use only one tag.

Commonly, a list of content-specific CSS classes is placed within the element allowing JavaScript developers and designers to target pages easily. Even if these classes are not used, they won’t cause any problems.

Syntax

The tag comes in pairs. The content is written between the opening () and closing () tags.

Example of the HTML tag:

html> html> head> title>Title of the document title> head> body> p>Content of the document p> body> html>

Result

body exemple

Example of the HTML tag used with the CSS color and line-height properties:

html> html> head> title>Title of the document title> style> body < color: #444444; line-height: 1.5; > style> head> body> h1>HTML body tag example h1> p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book. p> body> html>

Attributes

Attribute Value Description
alink color Defines the color of the active link.
Not used in HTML5.
background URL Defines the background image.
Not used in HTML5.
bgcolor color Defines the background color.
Not used in HTML5.
link color Defines the color of unvisited links.
Not used in HTML5.
text color Defines the color of the text in a document.
Not used in HTML5.
vlink color Defines the color of the visited link.
Not used in HTML5.

How to style tag?

Common properties to alter the visual weight/emphasis/size of text in tag:

  • CSS font-style property sets the style of the font. normal | italic | oblique | initial | inherit.
  • CSS font-family property specifies a prioritized list of one or more font family names and/or generic family names for the selected element.
  • CSS font-size property sets the size of the font.
  • CSS font-weight property defines whether the font should be bold or thick.
  • CSS text-transform property controls text case and capitalization.
  • CSS text-decoration property specifies the decoration added to text, and is a shorthand property for text-decoration-line, text-decoration-color, text-decoration-style.

Coloring text in tag:

  • CSS color property describes the color of the text content and text decorations.
  • CSS background-color property sets the background color of an element.

Text layout styles for tag:

  • CSS text-indent property specifies the indentation of the first line in a text block.
  • CSS text-overflow property specifies how overflowed content that is not displayed should be signalled to the user.
  • CSS white-space property specifies how white-space inside an element is handled.
  • CSS word-break property specifies where the lines should be broken.

Other properties worth looking at for tag:

  • CSS text-shadow property adds shadow to text.
  • CSS text-align-last property sets the alignment of the last line of the text.
  • CSS line-height property specifies the height of a line.
  • CSS letter-spacing property defines the spaces between letters/characters in a text.
  • CSS word-spacing property sets the spacing between words.

Источник

Tag in HTML

Javascript Course - Mastering the Fundamentals

In this article, you will learn about the HTML element called the tag. The body tag contains all the main content of the webpage such as headings, paragraphs, images, tables etc. It is always enclosed within the tag. Everything you see on the web browser will be present inside the tag.

HTML Tag

We all know that HTML is basically used to build websites that are available on the internet. HTML consists of series of elements like tag tag, etc that are used to structure the web page. One such element that is a home for all the other contents of the webpage such as headings, paragraphs, images, tables etc is HTML Tag.

All the content inside the tag is only visible on the webpage.

For example

HTML Body Tag

As shown in the example, the tag is always enclosed within the tag and there can be only one tag in the whole webpage. It is usually present after the tag. The content in the tag is written between the opening ( ) and closing ( ) tags.

Tag Specific Attributes

tag has some attributes that change the way the web pages looks. Let’s learn about a few of them.

Attribute Description
bgcolor Colour of the Background of your page
alink Color of text for links
background Image to be used as a background
link Color of text for links that are not visited
vlink Color of text for visited links
text Color of the text on your webpage
margins Used to add margins to the webpage

Window Event Attributes

There are some window event attributes that are script based and used within the tag.

Few examples are given below for your reference.

Attribute Description
ononline Script triggered when the browser starts to work online
onoffline Script triggered when the browser starts to work offline
onload Script triggered when the page is completely loaded
onerror Script triggered when an error occurs
onpageshow Script triggered when a user visits a page
onresize Script triggered when the browser window is resized

HTML Tag Usage

Below is an example of basic structure of a webpage with tag.

HTML Body Tag Usage

Explanation

  • The element contains all the contents of the webpage like the heading, paragraph, images, tables etc. Here element specifies a heading and

    element specifies a paragraph.

  • The elements contains all the contents of the webpage.
  • The element contains additional information about the HTML page like the page title.
  • The element specifies a title for the webpage which is shown in the browser’s window.

Below is another example tag usage with bgcolor attribute.

Body Tag in HTML BG Color

Explanation

The HTML bgcolor attribute is used to set the background color of an HTML element.

The Atrribute value can be anyone of the following:

  • colorname: The background color is set by using the color name. For example “yellow”
  • hexnumber: The background color is set using the color hex code. For example “#0000ff” .
  • rgbnumber: The background color is set by using the RGB code. For example: “RGB(0, 153, 0)” .

Supported Browsers

HTML tag is supported by all major web browsers. HTML Tag is supported by all major web browsers as it is the main html element.

Below is the list of some major supported browsers.

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari
  • Microsoft Edge

HTML Body Tag Browser Compatibility

Summary

  • The HTML tag contains all the main content of the webpage such as headings, paragraphs, images, tables etc.
  • All the content inside the tag is only visible on the webpage.
  • HTML Tag has attributes like bgcolor, text etc that change the way webpage looks.
  • HTML Tag is supported by all major web browsers as it is the main html element.

Источник

Оцените статью