Dofactory.com
Dofactory.com

HTML <blockquote> class Attribute

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

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

Classes, i.e. classnames, are used to style the blockquote 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

Classes (i.e. classnames) are used for styling the blockquote 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.


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>

Author: Jack Poorte
Published: Jun 20 2021
Last Reviewed: Sep 30 2023


What's your favorite/least favorite part of Dofactory?


Guides