HTML Attributes

Attributes Tell Us More About Elements

  • Attributes provide additional information about the element
  • The element and are made up of two parts: a name and a value
  • Attribute names and attribute values are case-insensitive
<p lang="en-us"> content is English </a>
lang ⇢ Here an attribute called lang is used to indicate the language used in this element
value ⇢ The value of this attribute on this page specifies it is in US English.

HTML Example

Common Attributes (Core Attributes)

id Attribute

The id attribute is a unique identifier which is used to specify the document also used by scripting languages to reference the element, no two id attributes should have the same value.

ID selector is a name preceded by a hash character (#)

HTML Example

class Attribute

  • Use a class when you want to consistently style multiple elements throughout the page/site.
  • You can use the same class on multiple elements.
  • You can use multiple classes on the same element.
A class selector is a name preceded by a full stop (.)

HTML Example

Style Attribute

The Style Attribute allows you to Css to with in the element (inline styleing)

HTML Example

title Attribute

The Style Attribute allows you to Css to with in the element (inline styleing)

HTML Example

© 2019 W3Samples.com. All Rights Reserved