HTML <footer> class Attribute

The class attribute on a <footer> tag assigns one or more classnames to the footer 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 <footer> element.

© Company, Ltd. All Rights Reserved.

<style>
  .footer-dark {background:darkslategray; color:white; padding:10px;}
</style>

<footer class="footer-dark">
  <p>&copy; Company, Ltd. All Rights Reserved.</p>
</footer>

Using class

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

Multiple classnames are separated by a space.

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

<footer class="classnames">

Values

#

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

More Examples

A class attribute styling a <footer> element.
Clicking the button toggles a classname that changes the background and text colors.

© Company, Ltd. All Rights Reserved.


<style>
  .footer-dark { background:#1f2936; color:white; padding:10px; }
  .footer-indigo { background:#c6d2fe; color:black; }
</style>

<footer id="myfooter" class="footer-dark">
  <p>&copy; Company, Ltd. All Rights Reserved.</p>
</footer>

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

<script>
  let toggle = () => {
    let element = document.getElementById("myfooter");
    element.classList.toggle("footer-indigo");
  }
</script>

Code explanation

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

The class attribute in <footer> assigns one classname.

Repeatedly clicking the button toggles the second class, changing the element's background and text color.


Browser support

Here is when class support started for each browser:

Chrome
6.0 Sep 2010
Firefox
4.0 Mar 2011
IE/Edge
9.0 Mar 2011
Opera
11.1 Mar 2011
Safari
5.0 Jun 2010

You may also like

 Back to <footer>
Guides