HTML Attributes

The Lang Attribute

The language of the document can be declared in the <html> tag.

The language is declared with the lang attribute.

Declaring a language is important for accessibility applications (screen readers) and search engines.

HTML Code:

<!DOCTYPE html> <html lang="en-US"> <body> ... </body> </html>

The Title Attribute

The value of the title attribute will be displayed as a tooltip when you mouse over the element.

HTML Code:

<p title="I'm a tooltip"> Mouse over this paragraph, to display the title attribute as a tooltip. </p>

Result:

Mouse over this paragraph, to display the title attribute as a tooltip.


Size Attributes

HTML images are defined with the <img> tag.

The filename of the source (src), and the size of the image (width and height) are all provided as attributes.

HTML Code:

<img src="html_symbol_01.jpg" width="100" height="100"> <img src="html_symbol_01.jpg" width="50" height="50">

Result:


The Alt Attribute

The alt attribute specifies an alternative text to be used, when an image cannot be displayed.

The value of the attribute can be read by screen readers. This way, someone "listening" to the webpage, e.g. a blind person, can "hear" the element.

HTML Code:

<img src="html_symbol_.jpg" alt="HTML Symbol" width="100" height="100"> <img src="html_symbol_01.jpg" alt="HTML Symbol" width="100" height="100">

Result:

HTML Symbol HTML Symbol

HTML Index

References

  1. W3Schools

This page is only a summary of the material from W3Schools. Definitions, Examples and Codes are exclusive property of W3Schools.