HTML Attributes

All HTML elements can have attributes. Which provide additional information about an element. They are always specified in the start tag. Its usually come in name/value pairs like: name=”value”.

The Href Attribute

HTML links are defined with the <a> tag. The link address is specified in the href attribute.

Example

<a href=”https://www.MediaProductionArt.com”>

The Src Attribute

HTML images are defined with the <img> tag. The filename of the image source is defined in the src attribute.

Example

<img src=”img_girl.jpg”>

The Alt Attribute

The alt attribute defines 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.

Example

<img src=”img_girl.jpg” alt=”Boy with a jacket”>

The style Attribute

The style attribute is used to define the styling of an element, like color, font, size etc.

Example

<p style=”color:red”>I am a paragraph</p>

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.

Example

<!DOCTYPE html>
<html lang=”en-US”>
<body>

</body>
</html>

The title Attribute

Here, a title attribute is added to the <p> element. The value of the title attribute will be displayed as a tooltip when you cursor over the paragraph.

Example

<p title=”I’m good”>