Attributes in HTML
Properties are used to add information to elements in HTML.
Properties are used to add information to elements in HTML.
Characteristics of HTML attributes
- All HTML elements have attributes
- Additional properties for the element information
- Attributes are usually specified in the opening tag
- Attributes often follow name-value pairs, such as ten = "giatri"
Href attribute
The path in HTML is determined by the tag and the path address is determined by the
href.
attribute href.
For example
Quản trị mạng
Src attribute
Images in HTML are determined by tags ,
,
the filename of the image source is determined by the src.
attribute src.
For example
Width and height attributes
Images in HTML also have properties that determine the size, width and height.
For example
The image size is determined in pixels, with a height of 200 pixels and a width of 540 pixels. There will be separate images in the following HTML for you to understand.
Alt attribute
The alt
attribute specifies the alternate text used when the image cannot be displayed. The value of this attribute can be read on the screen reader. As a result, people can 'listen' to the website, for example, visually impaired people can 'listen' to HTML elements.
For example
The alt
attribute is also useful if the image does not exist. Eg:
Style properties
style
attribute is used to define the style for an element, such as color, font, size .
For example
I like reading Network Administration
Lang attribute
Text language is defined from the card Language is defined by lang attribute. Language definition is very important for applications that support accessibility (such as screen readers) and search engines.
…
The first two letters define the language, and if you want to specify only the dialect, use the following 2 letters (US). This indicates the text used in American English.
Title attribute
The title
attribute is added to the element
with the value of the attribute displayed as a comment when you drag the mouse over the text.
For example
Tôi đang học HTML trên Quản trị mạng.
A few other notes
Use quotation marks for values
Although HTML5 is not required to have quotation marks for attribute values, W3C encourages you to use this mark. Sometimes using quotation marks is mandatory, as in the example below, the title will not display properly without a quotation mark, because it contains spaces.
Should I use double quotes or single quotes?
It is possible to use single quotation marks but double quotation marks are still more common in HTML. In some cases, when right in the attribute value already contains double quotation marks, it is advisable to use a single quotation mark, and vice versa.
hoặc
Previous article: Elements in HTML
The following article: Title tags in HTML
You should read it
- Style HTML with CSS
- Attribute in C #
- Attributes in jQuery
- Input element attributes in HTML
- The id attribute in HTML
- Style properties in HTML
- Introduction to HTML
- HTML DOM element in AngularJS
- How to change the file's attributes using the Attrib command
- 5 steps to learn a dynamic HTML web component profile
- ID selector in CSS
- Basic examples of HTML
Maybe you are interested
What is a touch pen for laptops? Classification of types of touch pens In the future, scientists will use crystals to encode information How to Use Google Voice Search How to Set Default Programs in Windows 8 World popular technologies thanks to Apple The ThinkPad X1 Carbon Ultrabook has a touch panel