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:
<link>tag to link our document to an external CSS document
<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
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.
<a href=“#linkToMe”>Go to element</a> <p id=“linkToMe”>Element to link to</p>
HTML Class Attribute
A class is similar to an id, but it has 2 major differences:
- A class name can be reused on many elements, whereas an id is only used for one specific element
- 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