Skip to main content
100%

Rectangles

✓ Published1🌍 Public
AAlim Bolar
Last edited Aug 5, 2022
Created on Aug 5, 2022
Forked from Circles

This example centers a single green rectangle on a gray SVG canvas, sized to half the viewport’s width and height. A pink page background and red SVG border frame the composition. The code uses vanilla JavaScript to query the SVG element via `document.querySelector`, reads its `clientWidth` and `clientHeight`, then sets the rectangle’s `x`, `y`, `width`, and `height` attributes dynamically. CSS styles the body and a `.center` class, while the rectangle receives its fill, yellow stroke, and stroke width through `setAttribute` calls.

AI-generated description

A bare minimum HTML page demonstrating use of CSS and JavaScript.

See also React Starter.

MIT Licensed

Similar vizzes