HTML <figure> class Attribute

The class attribute assigns one or more classnames to the <figure> tag.

Classnames are defined in a stylesheet or in a local <style> element.

Classes, i.e. classnames, are used to style elements.



A class attribute styling a <figure> element.

  .figure {display:inline-block;padding:10px;border: 3px solid #456;}

<figure class="figure">
  <img src="/img/html/sangiorgio.jpg">

Using class

Classes (i.e. classnames) are used for styling the figure element.

Multiple classnames are separated by a space.

JavaScript uses classes to access elements by classname.

Tip:  class is a global attribute that can be applied to any HTML element.


<figure class="classnames">



Value Description
classnames One or more space-separated class names.

More Examples

A class attribute styling a <figure> element.
Clicking the button toggles a classname that changes spacing -- creating a larger passpartout.

  .figure {display:inline-block;padding:10px;border: 3px solid #456;}
  .figure-spacing { padding:20px; }

<figure id="myfigure" class="figure">
  <img src="/img/html/sangiorgio.jpg">

<button onclick="toggle();">Toggle class</button>

  let toggle = () => {
    let element = document.getElementById("myfigure");

Code explanation

Two CSS classes are defined in the <style> element.

The class attribute in <figure> assigns one classname.

Repeatedly clicking the button toggles another class, changing the element's border radius.

Browser support

Here is when class support started for each browser:

6.0 Sep 2010
4.0 Mar 2011
9.0 Mar 2011
11.1 Mar 2011
5.0 Jun 2010

You may also like

 Back to <figure>

Last updated on Sep 30, 2023