List of attributes in HTML


Attributes provide additional information about HTML elements. To find out details about attributes in HTML, please read along the following article of Taimienphi.vn.


In the following article, Taimienphi.vn will introduce you to attributes in HTML. Also readers can refer to some other articles already on Taimienphi.vn to learn more about what HTML is.

Learn the properties in HTML

Table of Contents:
1. Attributes in HTML
1.1. The href attribute in HTML
1.2. The src attribute in HTML
1.3. Width and height attributes in HTML
1.4. The alt attribute in HTML
1.5. Style attributes in HTML
1.6. The lang attribute in HTML
1.7. The title attribute in HTML
1.8. Parentheses and quotes
1.9. Attributes in HTML
2. Some notes

1. Attributes in HTML

– All HTML elements have properties.

– Attributes that provide additional information about the element.

– Attributes are specified in the header of the card.

– Attributes often include name / value pairs, such as name = “value”.

1.1 href attribute in HTML

HTML links are identified by tags a. The link address is specified in the property href.

For example: Here is an example of the href attribute in HTML:

smoking in html

The result returned after using the href attribute in HTML looks like this:

beauty in html 2

1.2. The src attribute in HTML

By using the card img to insert images in HTML.

The file name of the image source is specified in the attribute src.

For example: Here is an example of the src attribute in HTML:

beauty in html 3

The result returned after using the src attribute in HTML has the following form:

beauty in html 4

1.3. Width and height attributes in HTML

Images in HTML also include attributes width and Cao, specify the image width and height.

For example: Here is an example of width and height attributes in HTML:

beauty in html 5

The result returned after using width and height attribute in HTML has the following form:

beauty in html 6

By default the width and height attributes use pixels, so width = “500” is 50 pixels wide.

1.4. The alt attribute in HTML

Properties alt Specifies the use of text instead if the image cannot be displayed.

Alternatively, we can use the screen reader to read the value of the alt attribute.

Example 1: Here is an example of the alt attribute in HTML:

crystal clear html 7

The result returned after using the alt attribute in HTML looks like this:

beauty in html 8

The alt attribute in HTML is also useful in cases if the image cannot be displayed (assuming if that image does not exist).

Example 2: In this example the image does not exist.

in crystal 9 html

The result returned after using the alt attribute looks like this:

beauty in html 10

1.5. Style attributes in HTML

The style attribute in HTML is used to specify the style of the element, such as color, font, size, etc.

For example: The following example uses the style attribute in HTML:

beauty in html 11

The result returned after using the style attribute looks like this:

beauty in html 12

1.6. The lang attribute in HTML

The language used in the document is declared in the tag html.

Language is declared by attribute lang.

Language declaration is extremely important, especially for accessibility applications (such as screen readers) and search engines.

For example: The example below uses lang attribute in HTML:

beauty in html 13

1.7. The title attribute in HTML

Properties title added to the element p. The title attribute value will be displayed as a tooltip when the user hovers over the text.

For example: The following example illustrates how to use the title attribute in HTML:

crystal clear html in 14

The result returned after using the title attribute looks like this:

smoking in html 15

1.8. Parentheses and quotes

In HTML, attribute values ​​are enclosed in quotes, but we can also use parentheses if we want.

In some cases if the attribute value itself contains quotes, we will have to use parentheses.

For example: The following example illustrates the use of parentheses and quotes in HTML:

beauty in html 16

Or as below are true:

Crystal in html 17

1.9. Attributes in HTML

The following table is a list of the most frequently used attributes in HTML:

crystal clear html in 18

2. Some notes

– HTML5 is not case sensitive when writing attribute names. In addition, we do not need to use quotes for attribute names.

https://thuthuat.taimienphi.vn/thuoc-tinh-trong-html-51106n.aspx
The article above Taimienphi.vn has just introduced you to the properties in HTML. In the next articles, Taimienphi.vn will introduce you more about the element in HTML. In addition, if you have any questions or questions, you can leave your comments in the comment section below the article.

.

Add a Comment

Your email address will not be published. Required fields are marked *