-
Notifications
You must be signed in to change notification settings - Fork 23k
docs: Add reference for CSS value serialization, especially colors #41322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixes mdn#32734 Adds a new guide explaining how CSS values especially colors are serialized when accessed via JavaScript APIs like getComputedStyle() and getPropertyValue().
|
Preview URLs
Flaws (108)URL:
URL:
URL:
(comment last updated: 2025-11-17 17:49:31) |
Josh-Cena
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of content is incomplete or duplicative. I suspect you are using AI to write this, which is fine in principle, but next time please disclose this because it's not the quality we are expecting for a ready-for-review PR. Also, you should document length serialization as well at least, since that's the other common use case.
files/en-us/web/api/css_object_model/serializing_css_values/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/serializing_css_values/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/serializing_css_values/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/serializing_css_values/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/serializing_css_values/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/serializing_css_values/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/serializing_css_values/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/serializing_css_values/index.md
Outdated
Show resolved
Hide resolved
|
Hi @Josh-Cena , Yes, I tried the Co-pilot version of Sonnet 3.5. I will keep it in mind to mentioned that in the PR, I was not sure, if we used Copilot need to raise as Draft PR or Ready to reviewPR. |
…dex.md Co-authored-by: Joshua Chen <[email protected]>
…ssab/content into css-value-serialization
|
Let me know if any changes need to be updated or any grammatical error . Happy to update it. Thanks for the review. |
|
We still need to link to it from many places, and possibly there are a lot of places that talk about value serialization (especially colors) that can be deduplicated. I will wait for @estelle. |
estelle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add the serialization format to all the data type pages in the future.
files/en-us/web/api/css_object_model/css_value_serialization/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/css_value_serialization/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/css_value_serialization/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/css_value_serialization/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/css_value_serialization/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/css_value_serialization/index.md
Outdated
Show resolved
Hide resolved
…ndex.md Co-authored-by: Estelle Weyl <[email protected]>
…ndex.md Co-authored-by: Estelle Weyl <[email protected]>
…ndex.md Co-authored-by: Estelle Weyl <[email protected]>
…ndex.md Co-authored-by: Estelle Weyl <[email protected]>
…ndex.md Co-authored-by: Estelle Weyl <[email protected]>
3dc8b26 to
fb9973c
Compare
|
The more I read into the specs and do tests, the more I believe that serialization is a hot mess and no one knows exactly how it works. I think just covering the basic data types is the most we can do, and even then I'm unsure because obviously the |
Josh-Cena
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@estelle PTAL, thanks
estelle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. Thank you. I just made a few grammar and linking suggestions. I also submitted a PR directly to your PR to add links to your guide from related CSS module landing pages. See Shrinivassab#1
| - {{domxref("CSSStyleDeclaration.cssText")}} | ||
| - Accessing properties directly on {{domxref("CSSStyleDeclaration")}} objects (e.g., `element.style.backgroundColor`) | ||
|
|
||
| Different APIs return `CSSStyleDeclaration` objects at different stages of [value processing](/en-US/docs/Web/CSS/Guides/Cascade/Property_value_processing), which have slightly different serialization behaviors. For example, {{domxref("Window.getComputedStyle()")}} and {{domxref("HTMLElement.style")}} returns the [resolved value](/en-US/docs/Web/CSS/Guides/Cascade/Property_value_processing#resolved_value) of properties, while {{domxref("CSSStyleRule.style")}} returns _more or less_ the [declared value](/en-US/docs/Web/CSS/Guides/Cascade/Property_value_processing#declared_value). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Different APIs return `CSSStyleDeclaration` objects at different stages of [value processing](/en-US/docs/Web/CSS/Guides/Cascade/Property_value_processing), which have slightly different serialization behaviors. For example, {{domxref("Window.getComputedStyle()")}} and {{domxref("HTMLElement.style")}} returns the [resolved value](/en-US/docs/Web/CSS/Guides/Cascade/Property_value_processing#resolved_value) of properties, while {{domxref("CSSStyleRule.style")}} returns _more or less_ the [declared value](/en-US/docs/Web/CSS/Guides/Cascade/Property_value_processing#declared_value). | |
| Different APIs return `CSSStyleDeclaration` objects at different stages of [value processing](/en-US/docs/Web/CSS/Guides/Cascade/Property_value_processing), which have slightly different serialization behaviors. For example, {{domxref("Window.getComputedStyle()")}} and {{domxref("HTMLElement.style")}} returns the [resolved value](/en-US/docs/Web/CSS/Guides/Cascade/Property_value_processing#resolved_value) of properties, while {{domxref("CSSStyleRule.style")}} return _more or less_ the [declared value](/en-US/docs/Web/CSS/Guides/Cascade/Property_value_processing#declared_value). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The subject is CSSStyleRule.style which is singular?
files/en-us/web/api/css_object_model/css_value_serialization/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/css_value_serialization/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/css_value_serialization/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/css_value_serialization/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/css_object_model/css_value_serialization/index.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Estelle Weyl <[email protected]>
estelle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 🎉
…41322) * docs: Add reference for CSS value serialization, especially colors Fixes #32734 Adds a new guide explaining how CSS values especially colors are serialized when accessed via JavaScript APIs like getComputedStyle() and getPropertyValue(). * Update files/en-us/web/api/css_object_model/serializing_css_values/index.md Co-authored-by: Joshua Chen <[email protected]> * Addressed PR comments * Rewrite * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Rewrite * Apply suggestions from code review Co-authored-by: Estelle Weyl <[email protected]> * Add guide links --------- Co-authored-by: Joshua Chen <[email protected]> Co-authored-by: Estelle Weyl <[email protected]> Co-authored-by: Estelle Weyl <[email protected]>
…41322) * docs: Add reference for CSS value serialization, especially colors Fixes #32734 Adds a new guide explaining how CSS values especially colors are serialized when accessed via JavaScript APIs like getComputedStyle() and getPropertyValue(). * Update files/en-us/web/api/css_object_model/serializing_css_values/index.md Co-authored-by: Joshua Chen <[email protected]> * Addressed PR comments * Rewrite * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Rewrite * Apply suggestions from code review Co-authored-by: Estelle Weyl <[email protected]> * Add guide links --------- Co-authored-by: Joshua Chen <[email protected]> Co-authored-by: Estelle Weyl <[email protected]> Co-authored-by: Estelle Weyl <[email protected]>
…41322) * docs: Add reference for CSS value serialization, especially colors Fixes #32734 Adds a new guide explaining how CSS values especially colors are serialized when accessed via JavaScript APIs like getComputedStyle() and getPropertyValue(). * Update files/en-us/web/api/css_object_model/serializing_css_values/index.md Co-authored-by: Joshua Chen <[email protected]> * Addressed PR comments * Rewrite * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Rewrite * Apply suggestions from code review Co-authored-by: Estelle Weyl <[email protected]> * Add guide links --------- Co-authored-by: Joshua Chen <[email protected]> Co-authored-by: Estelle Weyl <[email protected]> Co-authored-by: Estelle Weyl <[email protected]>
…41322) * docs: Add reference for CSS value serialization, especially colors Fixes #32734 Adds a new guide explaining how CSS values especially colors are serialized when accessed via JavaScript APIs like getComputedStyle() and getPropertyValue(). * Update files/en-us/web/api/css_object_model/serializing_css_values/index.md Co-authored-by: Joshua Chen <[email protected]> * Addressed PR comments * Rewrite * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Rewrite * Apply suggestions from code review Co-authored-by: Estelle Weyl <[email protected]> * Add guide links --------- Co-authored-by: Joshua Chen <[email protected]> Co-authored-by: Estelle Weyl <[email protected]> Co-authored-by: Estelle Weyl <[email protected]>
…41322) * docs: Add reference for CSS value serialization, especially colors Fixes #32734 Adds a new guide explaining how CSS values especially colors are serialized when accessed via JavaScript APIs like getComputedStyle() and getPropertyValue(). * Update files/en-us/web/api/css_object_model/serializing_css_values/index.md Co-authored-by: Joshua Chen <[email protected]> * Addressed PR comments * Rewrite * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Rewrite * Apply suggestions from code review Co-authored-by: Estelle Weyl <[email protected]> * Add guide links --------- Co-authored-by: Joshua Chen <[email protected]> Co-authored-by: Estelle Weyl <[email protected]> Co-authored-by: Estelle Weyl <[email protected]>
…41322) * docs: Add reference for CSS value serialization, especially colors Fixes #32734 Adds a new guide explaining how CSS values especially colors are serialized when accessed via JavaScript APIs like getComputedStyle() and getPropertyValue(). * Update files/en-us/web/api/css_object_model/serializing_css_values/index.md Co-authored-by: Joshua Chen <[email protected]> * Addressed PR comments * Rewrite * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Rewrite * Apply suggestions from code review Co-authored-by: Estelle Weyl <[email protected]> * Add guide links --------- Co-authored-by: Joshua Chen <[email protected]> Co-authored-by: Estelle Weyl <[email protected]> Co-authored-by: Estelle Weyl <[email protected]>
…41322) * docs: Add reference for CSS value serialization, especially colors Fixes #32734 Adds a new guide explaining how CSS values especially colors are serialized when accessed via JavaScript APIs like getComputedStyle() and getPropertyValue(). * Update files/en-us/web/api/css_object_model/serializing_css_values/index.md Co-authored-by: Joshua Chen <[email protected]> * Addressed PR comments * Rewrite * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Rewrite * Apply suggestions from code review Co-authored-by: Estelle Weyl <[email protected]> * Add guide links --------- Co-authored-by: Joshua Chen <[email protected]> Co-authored-by: Estelle Weyl <[email protected]> Co-authored-by: Estelle Weyl <[email protected]>
…41322) * docs: Add reference for CSS value serialization, especially colors Fixes #32734 Adds a new guide explaining how CSS values especially colors are serialized when accessed via JavaScript APIs like getComputedStyle() and getPropertyValue(). * Update files/en-us/web/api/css_object_model/serializing_css_values/index.md Co-authored-by: Joshua Chen <[email protected]> * Addressed PR comments * Rewrite * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Rewrite * Apply suggestions from code review Co-authored-by: Estelle Weyl <[email protected]> * Add guide links --------- Co-authored-by: Joshua Chen <[email protected]> Co-authored-by: Estelle Weyl <[email protected]> Co-authored-by: Estelle Weyl <[email protected]>
…41322) * docs: Add reference for CSS value serialization, especially colors Fixes #32734 Adds a new guide explaining how CSS values especially colors are serialized when accessed via JavaScript APIs like getComputedStyle() and getPropertyValue(). * Update files/en-us/web/api/css_object_model/serializing_css_values/index.md Co-authored-by: Joshua Chen <[email protected]> * Addressed PR comments * Rewrite * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Update files/en-us/web/api/css_object_model/css_value_serialization/index.md Co-authored-by: Estelle Weyl <[email protected]> * Rewrite * Apply suggestions from code review Co-authored-by: Estelle Weyl <[email protected]> * Add guide links --------- Co-authored-by: Joshua Chen <[email protected]> Co-authored-by: Estelle Weyl <[email protected]> Co-authored-by: Estelle Weyl <[email protected]>
Add reference for CSS value serialization, especially colors
Fixes #32734
Description
Adds a new guide explaining CSS value serialization through JavaScript APIs, with a focus on how color values (hsl(), hwb(), etc.) are serialized to rgb()/rgba() format when accessed via getComputedStyle() or getPropertyValue().
Motivation
This documentation helps developers understand why and how CSS values, especially colors, might return in different formats than they were written. This addresses a common source of confusion when working with CSS values through JavaScript APIs.
Additional details
References:
Related issues and pull requests
Fixes #32734 - Creates documentation for CSS value serialization, especially for colors