DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

CSSOM Explained: The CSS Object Model

CSSOM is the browser API model JavaScript uses to read and change CSS. Learn its key objects and how to work with inline styles, stylesheet rules, computed values, and CSSOM View.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • 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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • 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 CSSStyleRule and update its style declaration 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.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.