Заголовок страницы

Атрибуты тела документа html

Тег используется для размещения всего содержимого, которое отображается на веб-странице.

     

Заголовок 1

Это параграф.

Атрибуты тега :

  • onbeforeunload — сценарий, который выполнится, когда пользователь соберётся покинуть страницу.
  • onhashchange — сценарий, который выполнится при изменении URL.
  • onmessage — сценарий, который выполнится при получении сообщения от приложения.
  • onoffline — сценарий, который выполнится, когда браузер начнёт работать в автономном режиме.
  • ononline — сценарий для запуска, когда браузер начинает работать в режиме онлайн.
  • onpagehide — сценарий, который выполняется, когда пользователь переходит со страницы.
  • onpageshow — сценарий, который выполняется, когда пользователь переходит на страницу.
  • onunload — сценарий, который выполняется, когда пользователь покидает страницу.
  • onafterprint — сценарий, который выполнится после печати веб-страницы.
  • onbeforeprint — сценарий, который выполнится перед печатью веб-страницы.
  • onlanguagechange — сценарий, который выполнится при изменении языка документа.
  • onmessageerror — сценарий, который выполнится при возникновении ошибки в сообщении, полученном с помощью API Messaging.
  • onpopstate — сценарий, который выполнится при изменении состояния истории браузера.
  • onrejectionhandled — сценарий, который выполнится при обработке отклоненного обещания в объекте Promise .
  • onstorage — сценарий, который выполнится при изменении данных в объекте localStorage или sessionStorage .
  • onunhandledrejection — сценарий, который выполнится при возникновении отклоненного обещания в объекте Promise без обработки.

Примеры использования

     

Мой веб-сайт

Добро пожаловать на мой веб-сайт!

     

Мой веб-сайт

Добро пожаловать на мой веб-сайт!

Visit Example.com

Веб-страница с изображениями:

     

Мой веб-сайт

Добро пожаловать на мой веб-сайт!

Для чего использовать тег

  • Для отображения содержимого на веб-странице.
  • Для форматирования текста и другого содержимого с помощью HTML-тегов.
  • Для размещения ссылок на другие веб-страницы или ресурсы.
  • Для вставки мультимедийного содержимого, такого как изображения и видео.
  • Для стилизации содержимого с помощью CSS.
  • Для определения структуры веб-страницы с помощью HTML-тегов.

Глобальные атрибуты

Ограничения

Тег должен использоваться только один раз в HTML-документе. Он не может быть вложен внутрь другого тега или любого другого элемента.

Нюансы

  • Если в документе нет тега , браузер всё равно попытается отобразить страницу. Но полученная страница может быть плохо сформирована или в ней будет отсутствовать важное содержимое.
  • Если в HTML-документе несколько тегов , распознаётся только первый из них, а все последующие игнорируются.

👉🏻 Другие теги для создания структуры документа

«Доктайп» — журнал о фронтенде. Читайте, слушайте и учитесь с нами.

Источник

Атрибуты тела документа html

Элемент предназначен для хранения содержания веб-страницы (контента), отображаемого в окне браузера. Информацию, которую следует выводить в документе, следует располагать именно внутри контейнера . К такой информации относится текст, изображения, теги, скрипты JavaScript и т.д.

Читайте также:  Kotlin by class delegate

Тег также применяется для определения цветов ссылок и текста на веб-странице. Подобная практика в HTML 4 осуждается и взамен для указания цветовой схемы рекомендуется использовать стили, применяя их к селектору BODY . Тем не менее, большинство атрибутов до сих пор поддерживается разными браузерами.

Часто тег используется для размещения обработчика событий, например, onload, которое выполняется после того, как документ завершил загрузку в текущее окно или фрейм.

Открывающий и закрывающий теги на веб-странице не являются обязательными, однако хорошим стилем считается их использование, чтобы определить начало и конец HTML-документа.

Синтаксис

Атрибуты

alink Устанавливает цвет активной ссылки. background Задает фоновый рисунок на веб-странице. bgcolor Цвет фона веб-страницы. bgproperties Определяет, прокручивать фон совместно с текстом или нет. bottommargin Отступ от нижнего края окна браузера до контента. leftmargin Отступ по горизонтали от левого края окна браузера до контента. link Цвет ссылок на веб-странице. rightmargin Отступ от правого края окна браузера до контента. scroll Устанавливает, отображать полосы прокрутки или нет. text Цвет текста в документе. topmargin Отступ от верхнего края окна браузера до контента. vlink Цвет посещенных ссылок.

Также для этого тега доступны универсальные атрибуты и события.

Закрывающий тег

Открывающий и закрывающий теги не обязательны.

    

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diem nonummy nibh euismod tincidunt ut lacreet dolore magna aliguam erat volutpat.

Ut wisis enim ad minim veniam, quis nostrud exerci tution ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Результат текущего примера показан на рис. 1. При использовании события onload тега выполняется скрипт, написанный на языке JavaScript, в данном случае он выводит сообщение, что документ загружен.

Всплывающее окно в документе

Рис. 1. Всплывающее окно в документе

Статьи по теме

Источник

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.
Читайте также:  HTML-комментарии

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.

Источник

: The Document Body element

The HTML element represents the content of an HTML document. There can be only one element in a document.

Attributes

This element includes the global attributes.

Color of text for hyperlinks when selected. Do not use this attribute! Use the CSS color property in conjunction with the :active pseudo-class instead.

URI of an image to use as a background. Do not use this attribute! Use the CSS background property on the element instead.

Background color for the document. Do not use this attribute! Use the CSS background-color property on the element instead.

Читайте также:  Html фигура в фигуре

The margin of the bottom of the body. Do not use this attribute! Use the CSS margin-bottom property on the element instead.

The margin of the left of the body. Do not use this attribute! Use the CSS margin-left property on the element instead.

Color of text for unvisited hypertext links. Do not use this attribute! Use the CSS color property in conjunction with the :link pseudo-class instead.

Function to call after the user has printed the document.

Function to call when the user requests printing of the document.

Function to call when the document is about to be unloaded.

Function to call when the document loses focus.

Function to call when the document fails to load properly.

Function to call when the document receives focus.

Function to call when the fragment identifier part (starting with the hash ( ‘#’ ) character) of the document’s current address has changed.

Function to call when the preferred languages changed.

Function to call when the document has finished loading.

Function to call when the document has received a message.

Function to call when network communication has failed.

Function to call when network communication has been restored.

Function to call when the user has navigated session history.

Function to call when the user has moved forward in undo transaction history.

Function to call when the document has been resized.

Function to call when the storage area has changed.

Function to call when the user has moved backward in undo transaction history.

Function to call when the document is going away.

The margin of the right of the body. Do not use this attribute! Use the CSS margin-right property on the element instead.

Foreground color of text. Do not use this attribute! Use CSS color property on the element instead.

The margin of the top of the body. Do not use this attribute! Use the CSS margin-top property on the element instead.

Color of text for visited hypertext links. Do not use this attribute! Use the CSS color property in conjunction with the :visited pseudo-class instead.

Examples

html lang="en"> head> title>Document titletitle> head> body> p> The code><body>code> HTML element represents the content of an HTML document. There can be only one code><body>code> element in a document. p> body> html> 

Result

Specifications

Browser compatibility

BCD tables only load in the browser

See also

Found a content problem with this page?

This page was last modified on Jun 13, 2023 by MDN contributors.

Your blueprint for a better internet.

MDN

Support

Our communities

Developers

Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998– 2023 by individual mozilla.org contributors. Content available under a Creative Commons license.

Источник

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