MDN self-hosted library · e01.org

Fills and strokes

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<svg width="160" height="140" xmlns="http://www.w3.org/2000/svg">
  <rect
    x="10"
    y="10"
    width="100"
    height="100"
    stroke="blue"
    fill="purple"
    fill-opacity="0.5"
    stroke-opacity="0.8"
    stroke-width="15" />
</svg>
html
<svg width="400" height="180" xmlns="http://www.w3.org/2000/svg">
  <polyline
    points="40 80 80 40 120 80"
    stroke-width="15"
    stroke="black"
    fill="coral"
    paint-order="fill" />

  <polyline
    points="40 140 80 100 120 140"
    stroke-width="15"
    stroke="black"
    fill="coral"
    paint-order="stroke" />
</svg>
css
#MyRect:hover {
  stroke: black;
  fill: blue;
}
css
#MyRect {
  fill: red;
  stroke: black;
}