Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. SVG
  3. Reference
  4. Attributes
  5. class

class

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Assigns a class name or set of class names to an element. You may assign the same class name or names to any number of elements, however, multiple class names must be separated by whitespace characters.

An element's class name serves two key roles:

  • As a style sheet selector, for when an author assigns style information to a set of elements.
  • For general use by the browser.

You can use this class to style SVG content using CSS.

Usage context

CategoriesNone
Value<list-of-class-names>
AnimatableYes

Example

html
<html lang="en">  <body>    <svg      width="120"      height="220"      viewPort="0 0 120 120"      version="1.1"      xmlns="http://www.w3.org/2000/svg">      <style>        <![CDATA[          rect.rectClass {            stroke: #000066;            fill: #00cc00;          }          circle.circleClass {            stroke: #006600;            fill: #cc0000;          }        ]]>      </style>      <rect x="10" y="10" width="100" height="100" />      <circle cx="40" cy="50" r="26" />    </svg>  </body></html>

Elements

The following elements can use theclass attribute:

Specifications

Specification
Scalable Vector Graphics (SVG) 2
# ElementSpecificStyling

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp