HTML & CSS References

HTML Attributes

Attributes are special terms used within the opening HTML tag to provide extra context or information to the browser, and contribute to how the element behaves. HTML Attributes can be thought of like a modifier for an element type.

HTML Style Attribute

The style attribute is used to implement CSS styling to a specific element from within an HTML file. There are multiple different ways to add CSS styling to a document, and using the style attribute is only one way. 

We can use:

  • The <link> tag to link our document to an external CSS document
  • The <style> tag to include internal CSS for a document
  • The style attribute to include inline styling for a specific element

Generally, our preferred method for including CSS is by using the <link> tag and using an external CSS stylesheet.


HTML Lang Attribute

The HTML lang attribute is used to specify the language of the element’s content. Usually we’ll only see the lang attribute on the <html> tag, but this attribute can be included on any HTML element.


HTML Title Attribute

The title attribute is used to specify extra information about an element. The information is typically shown as a tooltip text when the mouse hovers over the element in question.


HTML ID Attribute

The id attribute is used to give a unique identifier to an HTML element. An id on an element should not be repeated within the document, as well, an element should only have 1 id. The id attribute can be used to target the element with JavaScript, CSS and even use some built in HTML functionality!

With JavaScript we can use the id attribute to target a specific element and increase  or modify the functionality that the element provides to the web page. 

With CSS we can use the id attribute to target the specific element and apply styling to the element. 

With HTML we can link together our anchor tag (<a>) and our target element by using the id on the target element and setting the href attribute of the anchor tag to the id value.

Example ID Attribute
<a href=“#linkToMe”>Go to element</a>
<p id=“linkToMe”>Element to link to</p>

HTML Class Attribute

The class attribute is used to specify a class name for an element. A class can be reused on other elements within a document to create a relationship between those elements. We can use class names in CSS to target these elements and apply styling to all of them. As well, we can use our class names to target all these elements using JavaScript and increase or modify the functionality that the elements provide to the page. 

A class is similar to an id, but it has 2 major differences:

  1. A class name can be reused on many elements, whereas an id is only used for one specific element
  2. With an id you can use an anchor tag to link to the element, whereas with a class you cannot.

Learn HTML & CSS Today

Get hands-on experience writing real code while you learn with interactive tutorials in our free online learning platform – no downloads or complicated setup required.

  • Free and fun
  • Designed for beginners
  • No download or setup required