The CSS Object Model (CSSOM) is the set of browser APIs JavaScript uses to inspect and change CSS-related state. It exposes stylesheets, rules, and declaration blocks as objects; it is related to the DOM, but it is not a second tree that simply mirrors the page.
What CSSOM means
CSS is the language used to describe presentation. CSSOM is the JavaScript-facing model browsers provide for working with CSS: scripts can access stylesheet and rule objects, read declarations, and make changes. The W3C CSSOM specification describes its core purpose as providing scripts with capabilities to access and manipulate style-related state and processes.
The DOM represents document structure and elements. CSSOM exposes CSS-related objects and operations. They interact—for example, JavaScript can find an element through the DOM and change its inline style—but CSSOM is not a parallel element tree.
The main CSSOM objects
| Object or entry point | What it represents | Typical use |
|---|---|---|
CSSStyleSheet |
A stylesheet and its operations. | Find or inspect a stylesheet and access its rules. |
CSSRule and derived interfaces such as CSSStyleRule |
A rule in a stylesheet. A style rule exposes selector text and its declarations. | Find a rule and inspect or update its selector or declarations. |
CSSStyleDeclaration |
An ordered block of CSS declarations. | Read or set property values on an element or rule. |
document.styleSheets |
The document’s associated stylesheet list. | Start enumerating stylesheets available through the document. |
Read and change an element’s inline style
An element’s style property gives access to its inline declarations as a CSSStyleDeclaration. This changes the element’s inline style; it does not edit a matching rule in a stylesheet.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware match#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
const card = document.querySelector(".card");
if (card) {
card.style.backgroundColor = "#f2f6ff";
card.style.setProperty("border-radius", "12px");
console.log(card.style.backgroundColor);
console.log(card.style.getPropertyValue("border-radius"));
}
CSS property names written in JavaScript generally use camel case, as in backgroundColor. The setProperty() and getPropertyValue() methods accept CSS property names such as border-radius.
Find and inspect associated stylesheets
document.styleSheets is a practical entry point. Stylesheet association can arise through elements such as <style> and <link>, @import, XML stylesheet instructions, and HTTP Link headers. The list is not a universal inventory of every stylesheet-like resource: for example, user-agent stylesheets and CSS module imports are exceptions noted in MDN’s documentation.
Rank #2
for (const sheet of document.styleSheets) {
console.log("Stylesheet:", sheet.href ?? "inline stylesheet");
for (const rule of sheet.cssRules) {
if (rule instanceof CSSStyleRule) {
console.log(rule.selectorText);
}
}
}
This example reads each sheet’s rules and logs selectors for style rules. It deliberately does not assume that every associated resource appears in the list or that every CSSOM interface behaves identically in every browser. Check the specific interface and feature you rely on in the target browser.
Change a stylesheet rule
A CSSStyleRule has a style declaration block, so a script can edit the rule’s declarations rather than adding an inline style to an element.
Rank #3
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
const sheet = document.querySelector("style")?.sheet;
if (sheet) {
const rule = [...sheet.cssRules].find(
item => item instanceof CSSStyleRule && item.selectorText === ".card"
);
if (rule) {
rule.style.setProperty("color", "#172033");
}
}
This example looks for a style rule in the first matching <style> element and updates its declaration. It does not create a rule if none exists. The selected stylesheet and rule determine the scope of the change.
Choose the right way to inspect or change styles
- Change one element’s inline declarations: use
element.style. This is direct and specific to that element. - Change a stylesheet rule: find its
CSSStyleRuleand update itsstyledeclaration block. This affects elements matched by the rule. - Read the style the browser resolves for an element: use
getComputedStyle(element). This is useful for inspecting resolved values, rather than just inline declarations. It returns a read-only style declaration object.
const element = document.querySelector(".card");
if (element) {
const resolved = getComputedStyle(element);
console.log(resolved.getPropertyValue("color"));
}
CSSOM View: geometry, viewport, and scrolling
CSSOM View is a related module, not a replacement for the core stylesheet, rule, and declaration model. It covers APIs for inspecting and manipulating a document’s visual view, including layout box positions, viewport dimensions, and scrolling. The cited W3C CSSOM View publication is a Working Draft dated 16 September 2025; W3C notes that Working Drafts may be updated, replaced, or obsoleted.
Rank #4
Support and practical limits
CSSOM features arrived at different times across browsers, so there is no single support answer for “CSSOM.” Verify compatibility for the particular interface or method your code uses against current browser compatibility data before depending on it. A general overview cannot establish support for every member of the API.
Also keep the target of an operation clear: editing an inline declaration, editing a stylesheet rule, and reading a computed value are distinct tasks. Choose the object that represents the state you intend to change or inspect.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Best Value
Or skip the browser setup
If what you need is an image or PDF of a page rather than programmatic access to its CSS, ScreenshotNeo offers a one-request screenshot API. Its capture can accept cookie or consent banners and remove known consent platforms, newsletter popups, and chat widgets before taking the shot; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. It also provides an MCP server for AI agents, with tools including take_screenshot, get_page_info, and capture_pdf.
For example, request a WebP screenshot of a page with cURL (see the ScreenshotNeo documentation for options and setup):
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.




