In HTML 5 the class attribute supports all HTML elements.
Applies To:
Element
Attribute
All HTML elements
class
class Attribute Values:
Value
Description
classname
classname is used to define one or more classes. For specify multiple classes for a single element by using space separated list.
Sample Coding for class Attribute in HTML:
Tryit<!DOCTYPE html><html><head><style>span.page{
font-size:120%;
color: orange;
}</style></head><body><h1>My<spanclass="page">HTML</span>program</h1><p>This is used to create<spanclass="page">Website</span>design.</p></body></html>
Code Explanation for class Attribute in HTML:
span.page is used to define a block of styles for a <span> element which has class name as page.
class attribute is used to set class name for the <span> tag.
page is a name of the class attribute that is used to get the styles for the <span> element.
Output for class Attribute in HTML:
The output displays the term HTML and Website in orange color by using class attribute.
html class taghtml class attributewhat is a class in htmlhtml class csshtml div idhtml class vs ididiv class htmlclass attribute htmldiv class cssdiv class containerspan class csshtml tutorialshtml editorhtml codehtml formhtmltutorialhtml colorhtml color codeshtml tablehtml imghtml5html code for websitehtml and csshtml programshtml websitefree html editorhtml5 tutorialwysiwyg html editorhtml tutorial pdfhtml converterphp tutorialhtml examplehtml tutorialcss tutorialhtml csshtml tagshtml basicscode htmlhtml onlinehtml mailtohtml langhtml tags listhtml attributes