codegurukool.com · Free coding tutorials & online compiler

Home › HTML Tutorial › Classes, ids and attributes

Classes, ids and attributes

Attributes add extra information to elements.

An id must be unique on a page. A class can be shared by many elements, and is how you target groups for CSS and JavaScript. title shows a tooltip.

Example code

<style>.note{background:#fff3c4;padding:8px}#main{border-left:4px solid orange;padding-left:8px}</style>
<p id="main" title="Hover me">Unique paragraph</p>
<p class="note">Note one</p>
<p class="note">Note two</p>

Run this code in the online editor

← Semantic layoutAudio and video →