top of page

HTML class

The HTML class attribute is used to specify a class for an HTML element.

Multiple HTML elements can share the same class.

The class attribute is often used to point to a class name in a style sheet. It can also be used by a JavaScript to access and manipulate elements with the specific class name.


<!DOCTYPE html>
.place {  % Class can be called by using dot (.) operator%
background-color: green;
  color: wred;
  border: 3px solid blue;
  margin: 25px;
  padding: 15px;

<div class="place">
<p>United state of America.</p>

<div class="Place">
<p>United Kingdom.</p>

We can also use multiple classes in one html by giving different class names.


The HTML id attribute is used to specify a unique id for an HTML element.

The same way as class we can use id for calling in style sheet as well as in java script. The ID in one html will be  unique. ID can be called by using # operator in css or js.


<p id="para">This is an example for declaring id</p>

%in style sheet or js we can call this id as #para.

bottom of page