HTML <blockquote> class Attribute

The class attribute on a <blockquote> tag assigns one or more classnames to the blockquote element. Classes are used to style elements. Classnames are defined in a stylesheet or in a local <style> element.

Example

#

A class attribute styling a <blockquote> element.

And so, my fellow Americans: ask not what your country can do for you – ask what you can do for your country. My fellow citizens of the world: ask not what America will do for you, but what together we can do for the freedom of man.
-- President Kennedy, 1961, Inaugural address.
<style>
  .blue-edge {border-left:4px solid lightblue; padding-left: 15px;}
</style>

<article>
  <blockquote class="blue-edge">
     And so, my fellow Americans: ask not what your country 
     can do for you – ask what you can do for your country. 
     My fellow citizens of the world: ask not what America 
     will do for you, but what together we can do for the 
     freedom of man.
 </blockquote>

 -- President Kennedy, 1961, Inaugural address.
</article>

Using class

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

Multiple classnames are separated by a space.

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

JavaScript uses classes to access one or more elements by classname.

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


Syntax

<blockquote class="classnames" >

Values

#

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

More Examples

A class attribute styling a <blockquote> tag.
Clicking the button toggles a classname that changes the border color.

And so, my fellow Americans: ask not what your country can do for you – ask what you can do for your country. My fellow citizens of the world: ask not what America will do for you, but what together we can do for the freedom of man.
-- President Kennedy, 1961, Inaugural address.


<style>
  .blue-edge { border-left: 4px solid lightblue; padding-left: 15px; }
  .red-edge { border-color: orangered; }
</style>

<article>
  <blockquote class="blue-edge" id="kennedyquote">
     And so, my fellow Americans: ask not what your country 
     can do for you – ask what you can do for your country. 
     My fellow citizens of the world: ask not what America 
     will do for you, but what together we can do for the 
     freedom of man.
 </blockquote>

 -- President Kennedy, 1961, Inaugural address.
</article>

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

<script>
  let toggle = () => {
     let element = document.getElementById("kennedyquote");
     element.classList.toggle("red-edge");
  }
</script>

Code explanation

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

The class attribute in <blockquote> assigns one classname.

Clicking the button toggles the second classname, changing the border color.


Browser support

Here is when class support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <blockquote>
Guides