
The class attribute assigns one or more CSS a class names to the <i> tag.
Class names are defined in a stylesheet or in a local <style> element.
Classes, i.e. class names, are used to style elements.
Example
A class attribute styling an <i> element.
Van Gogh and Gauguin visited Montpellier in December 1888.
Using class#
<style>
.i-underline { text-decoration: underline; }
</style>
<article>
<p>
Van Gogh and Gauguin visited
<i class=“i-underline”>Montpellier</i> in December 1888.
</p>
</article>
Try it live
Using class#
Classes (i.e. class names) are used for styling the i element.
Multiple class names are separated by a space.
JavaScript can use class names for fast access to one or more elements.
Syntax#
<i class=“classnames“>
Values
VALUE | DESCRIPTION |
classnames | One or more space-separated class names. |
More Examples#
A class attribute styling an <i> element.
Clicking the button toggles a classname that changes the background color.
Van Gogh and Gauguin visited Montpellier in December 1888.
Toggle class

class Attribute
<style>
class Attribute
.i-underline { text-decoration: underline; }
.lavender-bg { background-color:lavender; }
</style>
<article>
<p>
Van Gogh and Gauguin visited
<i id=“myi” class=“i-underline”>Montpellier</i>
in December 1888.
</p>
</article>
<br/>
<button onclick=“toggle();“>Toggle class</button>
<script>
let toggle = () => {
let element = document.getElementById(“myi”);
element.classList.toggle(“lavender-bg”);
</script>
Try it live
Code explanation
Three CSS classes are defined in the <style> element.
The class attribute in <i> assigns the two of those.
Repeatedly clicking the button toggles another class, changing the <i> underline
Browser support#
Here is when class support started for each browser:
1.0 | Sep 2008 | |
1.0 | Sep 2002 | |
1.0 | Aug 1995 | |
1.0 | Jan 2006 | |
1.0 | Jan 2003 |
HTML Tags
Tags are code constructs that define the elements which make up an HTML page.
Example elements include paragraph, image, link, input, video, navigation, and more.
Writing with tags:
- Tags start with a < and end with a > , for example, <img> which defines an image.
- Most tags have two parts, an opening tag and a closing tag.
- The closing tag has the same text as the opening tag, but prefixed with a ‘/’ (forward slash).
- A video player, for example, is created with these tags: <video> and </video>.
Here is a complete list of HTML tags that you can use to create web pages.
TAG | DESCRIPTION | |
<a> | Creates a link (hyperlink) to another page | Try it live |
<abbr> | Defines an abbreviation | Try it live |
<address> | Specifies contact information for the page’s author | Try it live |
<area> | Specifies a map area for an image | Try it live |
<article> | Defines a container for independent and self contained text | Try it live |
<aside> | Creates a content area that is related to the primary content on a page | Try it live |
<audio> | Creates a player for sound such as music, sound effects, or others | Try it live |
<b> | Specifies bold text | Try it live |
<base> | Sets the base URL for all relative URLs on a page | Try it live |
<blockquote> | Defines a section with text quoted from another source | Try it live |
<body> | Specifies a container for the page’s content with text, links, images, etc. | Try it live |
<br> | Creates a line break | Try it live |
<button> | Creates a clickable button that can contain text or an image | Try it live |
<canvas> | Creates a graphics container where JavaScript can draw. | Try it live |
<caption> | Specifies a caption for a table | Try it live |
<cite> | References the title of a body of work, e.g. book, art work, or a song | Try it live |
<code> | An element that is used to display computer code | Try it live |
<col> | Specifies column properties for a table | Try it live |
<colgroup> | Specifies one or more columns for table formatting purposes. | Try it live |
<data> | Links content to a machine-readable set of related data | Try it live |
<datalist> | Specifies a list of options for a textfield (<input>) element | Try it live |
<dd> | Adds a description of a term or name to a <dl> element | Try it live |
<del> | Marks deleted text | Try it live |
<details> | A control that can show and hide additional details | Try it live |
<div> | Creates a division or section on a page | Try it live |
<dl> | Defines a description list | Try it live |
<dt> | Adds a term or name to a <dl> element | Try it live |
<em> | Marks text that needs emphasis | Try it live |
<embed> | Creates a container for an external resource or plug-in | Try it live |
<fieldset> | Groups related form elements and displays a box with a legend around these | Try it live |
<figcaption> | Adds a caption to a <figure> (image) element | Try it live |
<figure> | Displays self-contained content, usually an image | Try it live |
<footer> | Defines a footer section on a page or a section of a page | Try it live |
<form> | Defines a data entry area that contains input elements | Try it live |
<h1>-<h6> | Defines text headings in 6 different sizes | Try it live |
<head> | Creates a head element that holds metadata elements | Try it live |
<header> | create Defines a header section on a page or a section of a page | Try it live |
<hr> | do Creates a horizontal line | Try it live |
<html> | Defines the root container for an HTML document | Try it live |
<i> | Specifies italic text | Try it live |
<iframe> | Creates a frame in which another web page can be embedded | Try it live |
<img> | Displays an image | Try it live |
<input> | Creates an input field in which data can be entered | Try it live |
<ins> | Marks inserted text | Try it live |
<kbd> | create Specifies keyboard input often with CTRL, SHIFT, or ALT | Try it live |
<label> | Creates a label or brief description before input elements | Try it live |
<legend> | Defines a caption for a fieldset | Try it live |
<li> | Defines a list item. Used in <ol> and <ul> elements | Try it live |
<link> | Defines a link to an external source, such as a style sheet | Try it live |
<main> | Specifies a container for the main content of the page | Try it live |
<map> | Defines a client-side image map, i.e. an image with clickable areas | Try it live |
<mark> | Displays marked or highlighted text | Try it live |
<meta> | Provides metadata about the web page | Try it live |
<meter> | Creates a measurement control, like a guage | Try it live |
<nav> | do Creates a container for navigation links | Try it live |
<noscript> | When the browser has disabled scripting, the noscript content displays | Try it live |
<object> | Embeds external objects in a page, such as, audio, video, image, or PDF | Try it live |
<ol> | Creates a numerically or alphabetically ordered list | Try it live |
<optgroup> | Groups related options in a <select> element (dropdown control) | Try it live |
<option> | Adds an item to a <select> element (dropdown control) | Try it live |
<output> | how to Displays output results of a calculation | Try it live |
<p> | Creates a paragraph | Try it live |
<param> | Adds parameters to an <object> element | Try it live |
<picture> | Adds images with a bit more flexibility than the <img> element | Try it live |
<pre> | Displays pre-formatted text in fixed-width font — usually computer code | Try it live |
<progress> | Creates a control that displays progress of a task | Try it live |
<q> | Creates a short quotation enclosed with quotation marks | Try it live |
<ruby> | Represents a small annotation with pronunciation of text | Try it live |
<samp> | Displays sample output from coumputer code | Try it live |
<script> | Adds JavaScript to a page. Either server-side or client-side | Try it live |
<section> | Defines a piece of content that can stand on its own | Try it live |
<select> | how Creates a dropdown control | Try it live |
<small> | Displays text in a smaller font size | Try it live |
<source> | Adds a media source for a <video>, <audio>, or <picture> | Try it live |
<span> | Container for one or more inline text elements | Try it live |
<strong> | Indicates text that is important or with high urgency | Try it live |
<style> | Adds CSS style elements to a page | Try it live |
<sub> | Marks subscript text where characters display lower and in smaller font | Try it live |
<summary> | Adds a heading to a <details> element. Clicking it toggles the details | Try it live |
<sup> | Marks superscript text where characters display higher and in smaller font | Try it live |
<svg> | start Creates an vector image | Try it live |
<table> | do Creates an HTML table with rows and columns, much like a spreadsheet | Try it live |
<tbody> | Marks the table body in an HTML table | Try it live |
<td> | do Creates an HTML table cell | Try it live |
<template> | then Creates a hidden content holder that can be copied by JavaScript | Try it live |
<textarea> | it Creates a multi-line text input control, for example for messages | Try it live |
<tfoot> | Marks the table footer in an HTML table | Try it live |
<th> | how Creates an HTML table header cell | Try it live |
<thead> | Marks the header rows in an HTML table | Try it live |
<time> | it Creates a human-readable date/time item | Try it live |
<title> | it Specifies the page title that will display in the browser’s tab | Try it live |
<tr> | Creates a table row with either <th> or <td> elements | Try it live |
<track> | Adds a text track, such as, subtitles and captions, to the media | Try it live |
<u> | how Specifies underlined text | Try it live |
<ul> | do you Creates an unordered, bulleted list | Try it live |
<var> | Defines its content as a variable | Try it live |
<video> | how to Creates a video player on a page | Try it live |
<wbr> | Adds a suggestion to the browser for a word-break location | Try it live |
<!DOCTYPE> | Specifies the HTML version on the first line of the page | Try it live |
<!–…–> | Marks text as comments in the source code. Not visible to users |