представляет заголовок документа. Большинство элементов HTML пишутся с начальным тегом (или открывающим) и конечным тегом (или закрывающим) с содержимым между ними. Элементы могут также содержать атрибуты, которые определяют его дополнительные свойства. Например, абзац, который представлен элементом , будет…

Содержание
  1. Руководство по атрибутам в HTML
  2. Атрибуты общего назначения
  3. Атрибут id
  4. Атрибут class
  5. Атрибут title
  6. Атрибут style
  7. Похожие посты
  8. Руководство по тегам и элементам в HTML
  9. Руководство по заголовкам в HTML
  10. до ; чем выше уровень заголовка, тем больше его важность — поэтому тег определяет самый важный заголовок, а тег определяет наименее важный заголовок в документе. По умолчанию браузеры отображают заголовки более крупным и жирным шрифтом, чем обычный… Руководство по мета-тегам в HTML Теги обычно используются для предоставления структурированных метаданных, таких как ключевые слова (keywords), описание (description), имя автора (author name), кодировка символов (character encoding) и т.д. В теге может быть размещено любое количество метатегов . Метаданные не будут отображаться на веб-странице, но будут обрабатываться поисковиками, браузерами и другими веб-сервисами. Теперь рассмотрим использование мета-тегов. Объявление кодировки… Разработка сайтов для бизнеса Если у вас есть вопрос, на который вы не знаете ответ — напишите нам, мы поможем разобраться. Мы всегда рады интересным знакомствам и новым проектам. Источник We have seen few HTML tags and their usage like heading tags , , paragraph tag and other tags. We used them so far in their simplest form, but most of the HTML tags can also have attributes, which are extra bits of information. Attribute names and attribute values are case-insensitive. However, the World Wide Web Consortium (W3C) recommends lowercase attributes/attribute values in their HTML 4 recommendation. Example This is left aligned This is center aligned This is right aligned This will display the following result − Core Attributes The four core attributes that can be used on the majority of HTML elements (although not all) are − The Id Attribute The id attribute of an HTML tag can be used to uniquely identify any element within an HTML page. There are two primary reasons that you might want to use an id attribute on an element − If an element carries an id attribute as a unique identifier, it is possible to identify just that element and its content. If you have two elements of the same name within a Web page (or style sheet), you can use the id attribute to distinguish between elements that have the same name. We will discuss style sheet in separate tutorial. For now, let’s use the id attribute to distinguish between two paragraph elements as shown below. This para explains what is HTML This para explains what is Cascading Style Sheet The title Attribute The title attribute gives a suggested title for the element. They syntax for the title attribute is similar as explained for id attribute − The behavior of this attribute will depend upon the element that carries it, although it is often displayed as a tooltip when cursor comes over the element or while the element is loading. Titled Heading Tag Example This will produce the following result − Now try to bring your cursor over «Titled Heading Tag Example» and you will see that whatever title you used in your code is coming out as a tooltip of the cursor. The class Attribute The class attribute is used to associate an element with a style sheet, and specifies the class of element. You will learn more about the use of the class attribute when you will learn Cascading Style Sheet (CSS). So for now you can avoid it. The value of the attribute may also be a space-separated list of class names. For example − class = "className1 className2 className3" The style Attribute The style attribute allows you to specify Cascading Style Sheet (CSS) rules within the element. Some text. This will produce the following result − At this point of time, we are not learning CSS, so just let’s proceed without bothering much about CSS. Here, you need to understand what are HTML attributes and how they can be used while formatting content. Internationalization Attributes There are three internationalization attributes, which are available for most (although not all) XHTML elements. The dir Attribute The dir attribute allows you to indicate to the browser about the direction in which the text should flow. The dir attribute can take one of two values, as you can see in the table that follows − Value Meaning ltr Left to right (the default value) rtl Right to left (for languages such as Hebrew or Arabic that are read right to left) This is how IE 5 renders right-to-left directed text. This will produce the following result − When dir attribute is used within the tag, it determines how text will be presented within the entire document. When used within another tag, it controls the text’s direction for just the content of that tag. The lang Attribute The lang attribute allows you to indicate the main language used in a document, but this attribute was kept in HTML only for backwards compatibility with earlier versions of HTML. This attribute has been replaced by the xml:lang attribute in new XHTML documents. The values of the lang attribute are ISO-639 standard two-character language codes. Check HTML Language Codes: ISO 639 for a complete list of language codes. This page is using English Language This will produce the following result − The xml:lang Attribute The xml:lang attribute is the XHTML replacement for the lang attribute. The value of the xml:lang attribute should be an ISO-639 country code as mentioned in previous section. Generic Attributes Here’s a table of some other attributes that are readily usable with many of the HTML tags. Attribute Options Function align right, left, center Horizontally aligns tags valign top, middle, bottom Vertically aligns tags within an HTML element. bgcolor numeric, hexidecimal, RGB values Places a background color behind an element background URL Places a background image behind an element id User Defined Names an element for use with Cascading Style Sheets. class User Defined Classifies an element for use with Cascading Style Sheets. width Numeric Value Specifies the width of tables, images, or table cells. height Numeric Value Specifies the height of tables, images, or table cells. title User Defined «Pop-up» title of the elements. We will see related examples as we will proceed to study other HTML tags. For a complete list of HTML Tags and related attributes please check reference to HTML Tags List. Источник
  11. определяет самый важный заголовок, а тег определяет наименее важный заголовок в документе. По умолчанию браузеры отображают заголовки более крупным и жирным шрифтом, чем обычный…
  12. Руководство по мета-тегам в HTML
  13. Example
  14. Core Attributes
  15. The Id Attribute
  16. The title Attribute
  17. Hello HTML!
  18. The class Attribute
  19. The style Attribute
  20. Internationalization Attributes
  21. The dir Attribute
  22. The lang Attribute
  23. The xml:lang Attribute
  24. Generic Attributes
Читайте также:  Php число через запятую

Руководство по атрибутам в HTML

Атрибуты определяют дополнительные характеристики или свойства элемента, например ширину и высоту изображения. Атрибуты всегда указываются в начальном теге (или открывающем) и обычно состоят из пар имя=значение, например name=»value» . Значения атрибутов всегда должны быть заключены в кавычки.

Для указания значений атрибутов могут использоваться как одинарные, так и двойные кавычки. Тем не менее, двойные кавычки являются наиболее распространенными. В ситуациях, когда само значение атрибута содержит двойные кавычки, необходимо заключить значение в одинарные кавычки, например, value=’John «Williams» Jr.’ и наоборот.

В HTML5 есть несколько атрибутов, которые не состоят из пар имя=значение, а состоят только из имени. Такие атрибуты называются булевыми (логическими) атрибутами. Примеры некоторых обычно используемых логических атрибутов: checked , disabled , readonly , required и т.д.

Подробно обо всех этих элементах вы узнаете в следующих главах.

Значения атрибутов обычно нечувствительны к регистру, за исключением определенных значений атрибутов, таких как id и class . Однако Валидатор W3C рекомендует использовать строчные буквы для указания значений атрибутов в их спецификации.

Атрибуты общего назначения

Есть некоторые атрибуты, такие как id , title , class , style и т. д., которые вы можете использовать в большинстве HTML-элементов. Остановимся на них подробнее.

Атрибут id

Атрибут id используется для присвоения уникального имени или идентификатора элементу в документе. Это облегчает выбор элемента с использованием CSS или JavaScript.

 
Некоторый контент

Это абзац.

id должен быть уникальным в пределах одного документа. Нельзя использовать два одинаковых id в одном документе и нельзя присваивать одному элементу два разных id .

Атрибут class

Как и атрибут id , атрибут class используется для идентификации элементов. Но в отличие от id , атрибут class не обязательно должен быть уникальным в документе. Это означает, что вы можете применить один и тот же класс к нескольким элементам в документе, как показано в следующем примере:

Читайте также:  64 битное окружение java jre установите jre

 
Некоторый контент

Это абзац.

Поскольку class может быть применен к нескольким элементам, любые CSS-правила, написанные для этого класса, будут применяться ко всем элементам, имеющим этот class .

Атрибут title

Атрибут title используется для предоставления дополнительного объяснительного текста об элементе или его содержимом. Посмотрим следующий пример, чтобы понять, как это работает.

Значение атрибута title (то есть текст заголовка) отображается в виде всплывающей подсказки веб-браузерами, когда пользователь наводит курсор мыши на элемент.

Атрибут style

Атрибут style позволяет указывать правила стилевого CSS-оформления, такие как color (цвет), font (шрифт), border (границы) и т. д. непосредственно внутри элемента. Посмотрим на пример, чтобы увидеть, как это работает:

Это абзац.

Cloudy Sky
Некоторый контент

Вы узнаете больше о стилизации HTML-элементов в Руководстве по стилям в HTML.

Атрибуты, которые мы обсуждали выше, также называются глобальными атрибутами. Подробнее см. Руководство по глобальным атрибутам в HTML5.

beget banner 480x320 flexbe banner 480x320 skillbox banner 480x320

Насколько публикация полезна?

Нажмите на звезду, чтобы оценить!

Средняя оценка 5 / 5. Количество оценок: 3

Оценок пока нет. Поставьте оценку первым.

Похожие посты

Руководство по тегам и элементам в HTML

HTML-элемент — это отдельный компонент документа HTML. Он представляет собой семантику или некоторое значение. Например, элемент

Руководство по заголовкам в HTML

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

до ; чем выше уровень заголовка, тем больше его важность — поэтому тег

определяет самый важный заголовок, а тег определяет наименее важный заголовок в документе. По умолчанию браузеры отображают заголовки более крупным и жирным шрифтом, чем обычный…

Руководство по мета-тегам в HTML

Теги обычно используются для предоставления структурированных метаданных, таких как ключевые слова (keywords), описание (description), имя автора (author name), кодировка символов (character encoding) и т.д. В теге может быть размещено любое количество метатегов . Метаданные не будут отображаться на веб-странице, но будут обрабатываться поисковиками, браузерами и другими веб-сервисами. Теперь рассмотрим использование мета-тегов. Объявление кодировки…

Разработка сайтов для бизнеса

Если у вас есть вопрос, на который вы не знаете ответ — напишите нам, мы поможем разобраться. Мы всегда рады интересным знакомствам и новым проектам.

Источник

We have seen few HTML tags and their usage like heading tags , , paragraph tag and other tags. We used them so far in their simplest form, but most of the HTML tags can also have attributes, which are extra bits of information.

Attribute names and attribute values are case-insensitive. However, the World Wide Web Consortium (W3C) recommends lowercase attributes/attribute values in their HTML 4 recommendation.

Example

     

This is left aligned

This is center aligned

This is right aligned

This will display the following result −

Core Attributes

The four core attributes that can be used on the majority of HTML elements (although not all) are −

The Id Attribute

The id attribute of an HTML tag can be used to uniquely identify any element within an HTML page. There are two primary reasons that you might want to use an id attribute on an element −

  • If an element carries an id attribute as a unique identifier, it is possible to identify just that element and its content.
  • If you have two elements of the same name within a Web page (or style sheet), you can use the id attribute to distinguish between elements that have the same name.

We will discuss style sheet in separate tutorial. For now, let’s use the id attribute to distinguish between two paragraph elements as shown below.

This para explains what is HTML

This para explains what is Cascading Style Sheet

The title Attribute

The title attribute gives a suggested title for the element. They syntax for the title attribute is similar as explained for id attribute −

The behavior of this attribute will depend upon the element that carries it, although it is often displayed as a tooltip when cursor comes over the element or while the element is loading.

     

Titled Heading Tag Example

This will produce the following result −

Now try to bring your cursor over «Titled Heading Tag Example» and you will see that whatever title you used in your code is coming out as a tooltip of the cursor.

The class Attribute

The class attribute is used to associate an element with a style sheet, and specifies the class of element. You will learn more about the use of the class attribute when you will learn Cascading Style Sheet (CSS). So for now you can avoid it.

The value of the attribute may also be a space-separated list of class names. For example −

class = "className1 className2 className3"

The style Attribute

The style attribute allows you to specify Cascading Style Sheet (CSS) rules within the element.

     

Some text.

This will produce the following result −

At this point of time, we are not learning CSS, so just let’s proceed without bothering much about CSS. Here, you need to understand what are HTML attributes and how they can be used while formatting content.

Internationalization Attributes

There are three internationalization attributes, which are available for most (although not all) XHTML elements.

The dir Attribute

The dir attribute allows you to indicate to the browser about the direction in which the text should flow. The dir attribute can take one of two values, as you can see in the table that follows −

Value Meaning
ltr Left to right (the default value)
rtl Right to left (for languages such as Hebrew or Arabic that are read right to left)
     This is how IE 5 renders right-to-left directed text.  

This will produce the following result −

When dir attribute is used within the tag, it determines how text will be presented within the entire document. When used within another tag, it controls the text’s direction for just the content of that tag.

The lang Attribute

The lang attribute allows you to indicate the main language used in a document, but this attribute was kept in HTML only for backwards compatibility with earlier versions of HTML. This attribute has been replaced by the xml:lang attribute in new XHTML documents.

The values of the lang attribute are ISO-639 standard two-character language codes. Check HTML Language Codes: ISO 639 for a complete list of language codes.

     This page is using English Language  

This will produce the following result −

The xml:lang Attribute

The xml:lang attribute is the XHTML replacement for the lang attribute. The value of the xml:lang attribute should be an ISO-639 country code as mentioned in previous section.

Generic Attributes

Here’s a table of some other attributes that are readily usable with many of the HTML tags.

Attribute Options Function
align right, left, center Horizontally aligns tags
valign top, middle, bottom Vertically aligns tags within an HTML element.
bgcolor numeric, hexidecimal, RGB values Places a background color behind an element
background URL Places a background image behind an element
id User Defined Names an element for use with Cascading Style Sheets.
class User Defined Classifies an element for use with Cascading Style Sheets.
width Numeric Value Specifies the width of tables, images, or table cells.
height Numeric Value Specifies the height of tables, images, or table cells.
title User Defined «Pop-up» title of the elements.

We will see related examples as we will proceed to study other HTML tags. For a complete list of HTML Tags and related attributes please check reference to HTML Tags List.

Источник

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