Tutorials

KodeKite Tools

HTML
Flexbox
SVG
Canvas
HTML Tutorial

More


HTML Class Attribute
Class Attribute

Class attribute indicate the class of element, it is non-unique once you have defined class you can use it many times as you want, class is denoted by putting period or dot. symbol before class name, all properties are listed in body of class in curly brackets {} and class attribute is used along with style.

Syntax

.className{
property:value;
property:value;
property:value;
}


You can create any number of classes with differet names.


Note:

You can give any name to class but don’t forget to put period symbol . before class name;


Example

I am paragraph with class ".p"


Don't forget that class is not unique for every element it can be same for two, three or all elements.


Practice Task

Open notepad or any other text editor, follow the following points.


  • Create any HTML element
  • Give it an class with name myclass
  • Inside class put color property with olives value
  • also put font size property with value 20px
  • also put font family property with value arial

save file with name task.html or task.htm and then open it using any browser and see results.


Solution

I have class named .myclass


You can give class to any element.