CKTIS / CSS
x — SVG horizontal coordinate
The CSS `x` property sets an SVG element's horizontal coordinate. It accepts a length or a percentage of the current SVG viewport's width.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
x: <length-percentage>;x sets horizontal position. The SVG 2 property table lists svg, rect, image, and foreignObject. Its initial value is 0; it is not inherited.
The syntax is x: <length-percentage>. Negative values are allowed. Percentages refer to the current SVG viewport's width, not the shape's width.
On rect, a CSS declaration can override the x presentation attribute. Do not equate it with every attribute sharing that name: x on text and tspan is not a presentation attribute for this property.
In the example, the #box rule overrides x="10". When run in Chromium, the example displayed the expected output x=50.
Examples
<!doctype html>
<meta charset="utf-8">
<title>CSS x</title>
<style>
#box { x: 25%; fill: navy; }
</style>
<svg width="200" height="80" viewBox="0 0 200 80">
<rect id="box" x="10" y="20" width="40" height="30" />
</svg>
<pre id="result"></pre>
<script>
const box = document.getElementById('box');
document.getElementById('result').textContent =
`x=${box.getBBox().x}`;
</script>Result
x=50
This code was run in an isolated Chromium 157.0.8103.51 environment with external requests blocked. The page text was checked for the expected output `x=50`.