stroke-width

CSS stroke-width Property

The CSS stroke-width property specifies the width of the stroke on the element.

The presentation attribute will be overridden: e.g. <path stroke-width=“3px” … />. The inline style won’t be overridden: e.g. <path style=“stroke-width: 3px;” … />.

The stroke-width is a presentation attribute and can be applied to any element but can have an effect only on the following elements: <altGlyph>, <circle>, <ellipse>, <ine>, <path>, <polygon>, <polyline>, <rect>, <text>, <textPath>, <tref>, and <tspan>.

“Px” or “em” units are not required.

类目类目
Initial Value1
Applies toShapes and text content elements.
InheritedYes.
AnimatableNo.
VersionSVG 1.1 Specification
DOM SyntaxObject.strokeWidth = “0.5”;

Syntax

Syntax

stroke-width: length | percentage | initial | inherit;

Example of the stroke-width property:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <h2>Stroke-width property example</h2>
    <svg viewBox="0 0 30 10">
      <circle cx="5" cy="5" r="3" stroke="#1c87c9" stroke-width="1" />
    </svg>
  </body>
</html>

Result

Example of the stroke-width property with the “length” value:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <h2>Stroke-width property example</h2>
    <svg viewBox="0 0 30 10">
      <circle cx="5" cy="5" r="3" stroke="#1c87c9" stroke-width="3" />
    </svg>
  </body>
</html>

Example of the stroke-width property with the “%” value:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <h2>Stroke-width property example</h2>
    <svg viewBox="0 0 30 10">
      <circle cx="5" cy="5" r="3" stroke="#1c87c9" stroke-width="2%" />
    </svg>
  </body>
</html>

Values

Values

ValueDescription
lengthSpecifies the width of the stroke.
percentageSpecifies the width of the stroke in %.
initialMakes the property use its default value.
inheritInherits the property from its parents element.


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部