HTML Classes



The HTML class attribute is used to create a single or multiple classes for HTML elements.

This class name can be used by javascript and css to attempt certain tasks for HTML elements with the selected class name.


Example

<!DOCTYPE html>
<html>
<head>
	<style>
		.myclass{ 
			color: yellow;
			background-color: red; }
	</style>
</head>
<body>
<h1 class="myclass">This is first heading</h1>
<h2 class="myclass">This is Second heading</h2>
<h3 class="myclass">This is third heading</h3>
<h4 class="myclass">This is fourth heading</h4>
</body>
</html>


Click on the "Run This Code" button to see how it works.





HTML

Welcome HTML Getting Started HTML Elements HTML Attributes HTML Headings HTML Paragraphs HTML Links HTML Styles HTML Text Formatting HTML Tables HTML Images HTML Forms HTML Lists HTML Iframes HTML Comments HTML CSS HTML Colors HTML Classes HTML Id HTML javascript HTML Filepaths

HTML Advanced

HTML Doctypes HTML Validation HTML Validation HTML URL HTML URL Encode HTML URL Entities HTML Layout HTML Head HTML Meta HTML Scripts HTML Tags

HTML Media

HTML Media HTML Audio HTML Video HTML Plug-ins HTML Youtube

HTML Graphics

HTML Canvas HTML SVG