Skip to content

Conversation

estelle
Copy link
Member

@estelle estelle commented Sep 3, 2025

syntax copies anchor()

original made it seem like the parameter had to be a number. made it clear what the options are.

Samsung is the only non-supporting browser.

@estelle estelle requested a review from a team as a code owner September 3, 2025 21:17
@estelle estelle requested review from dipikabh and removed request for a team September 3, 2025 21:17
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs size/s [PR only] 6-50 LoC changed labels Sep 3, 2025
The parameter is:

- `<calc-sum>`
- : An expression, or calculation, which resolves to a {{cssxref("number")}}, {{cssxref("length")}}, {{cssxref("percentage")}} or a {{cssxref("calc-keyword"). .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
- : An expression, or calculation, which resolves to a {{cssxref("number")}}, {{cssxref("length")}}, {{cssxref("percentage")}} or a {{cssxref("calc-keyword"). .
- : An expression, or calculation, which resolves to a {{cssxref("number")}}, {{cssxref("length")}}, {{cssxref("percentage")}} or a {{cssxref("calc-keyword"). .

Copy link
Contributor

github-actions bot commented Sep 3, 2025

Preview URLs

Flaws (2)

URL: /en-US/docs/Web/CSS/abs
Title: abs()
Flaw count: 2

  • macros:
    • Macro produces link /en-US/docs/Learn_web_development/Core/Styling_basics/Fundamental_CSS_comprehension which is a redirect
    • Macro produces link /en-US/docs/Learn_web_development/Core/Styling_basics/Cool-looking_box which is a redirect

(comment last updated: 2025-09-03 21:25:14)

Fix formatting issue in parameter description.
Comment on lines +20 to +27
The `abs()` function's syntax is as follows:

- `x`
- : A calculation which resolves to a number.
```plain
abs( <calc-sum>)
```

The parameter is:

Copy link
Member

@Josh-Cena Josh-Cena Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the new convention? Because this would go against all other references that use "Parameters", which all generally only include a DL. Our page template: https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Page_structures/Page_types/CSS_function_page_template#parameters also does not include this part. This should probably go into the syntax box above:

/* abs( <calc-sum> ) */
abs(20% - 100px)

(In other news we need to remove width: and property: from the syntax)

I'm not against the convention you are proposing here, but we should document it in the page template here, which may also help resolve #40500, alternatively we should consider #40500 a prerequisite, because if we settled on the approach I proposed above, then we can simply remove all this introduction.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't think we should add syntax to the "Parameters" section. The first and most obvious reason is that that would make this section inconsistent with our template for CSS functions. Another is that this syntax is too simplistic compared to what we show in Formal syntax, where each value expands into more further underlying expressions - this could become a problem if we try to apply this approach to other function pages.
(side note: not sure why "Formal syntax" is not showing up in the preview, it's there on prod)
A third reason is that we don't follow this convention on property pages either (in the "Values" section), so adding it here would introduce more inconsistency.

anchor() is probably not the best example to follow for this. asin() and clamp() are better aligned with the template (minus the "Syntax" block).

As for the "Syntax" block, although the template says:

Only include the function itself, not a complete declaration in which it occurs....Don't end the syntax lines with semicolons: this should emphasize that we are not showing complete valid CSS code here, just the syntax usage.

Currently this is pretty inconsistent across our function pages.
I don't quite agree with this part of the CSS function template (I believe there was extensive discussion around it before settling on that convention). Since our "Syntax" blocks are really more like "example usage", I think this block should include the complete usage with the property name and ;.

Copy link
Member

@Josh-Cena Josh-Cena Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A function is not a property value. Writing property: function(x); in a syntax box assumes more context than readers can assume. Using this syntax, we cannot possibly infer that calc(1px * abs(x)) is valid syntax, because in fact, we do have CSS functions that only work at a property-value-level and cannot be nested; currently the only case is toggle() which is unimplemented but specified, but this remains a real concern. In JS and Web API, our method syntax is minimal for this purpose: we don't say const y = await someObject.doSomething(x), we say doSomething(x), because someObject may be inferred as an identifier, where in fact it can be substituted by any JS value; the method may not be necessary awaited; and it may not be necessarily assigned to an identifier. we only document the syntax that readers can absolutely expect, not peripheral things that may be composed with it.

Comment on lines +20 to +27
The `abs()` function's syntax is as follows:

- `x`
- : A calculation which resolves to a number.
```plain
abs( <calc-sum>)
```

The parameter is:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't think we should add syntax to the "Parameters" section. The first and most obvious reason is that that would make this section inconsistent with our template for CSS functions. Another is that this syntax is too simplistic compared to what we show in Formal syntax, where each value expands into more further underlying expressions - this could become a problem if we try to apply this approach to other function pages.
(side note: not sure why "Formal syntax" is not showing up in the preview, it's there on prod)
A third reason is that we don't follow this convention on property pages either (in the "Values" section), so adding it here would introduce more inconsistency.

anchor() is probably not the best example to follow for this. asin() and clamp() are better aligned with the template (minus the "Syntax" block).

As for the "Syntax" block, although the template says:

Only include the function itself, not a complete declaration in which it occurs....Don't end the syntax lines with semicolons: this should emphasize that we are not showing complete valid CSS code here, just the syntax usage.

Currently this is pretty inconsistent across our function pages.
I don't quite agree with this part of the CSS function template (I believe there was extensive discussion around it before settling on that convention). Since our "Syntax" blocks are really more like "example usage", I think this block should include the complete usage with the property name and ;.

@@ -17,17 +17,23 @@ width: abs(20% - 100px);

### Parameters

The `abs(x)` function accepts only one value as its parameter.
The `abs()` function's syntax is as follows:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should keep the fact that it takes only one parameter

Comment on lines +28 to +29
- `<calc-sum>`
- : An expression, or calculation, which resolves to a {{cssxref("number")}}, {{cssxref("length")}}, {{cssxref("percentage")}} or a {{cssxref("calc-keyword").
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as per the Formal syntax, length should be dimension?

Suggested change
- `<calc-sum>`
- : An expression, or calculation, which resolves to a {{cssxref("number")}}, {{cssxref("length")}}, {{cssxref("percentage")}} or a {{cssxref("calc-keyword").
- `<calc-sum>`
- : An expression or calculation that resolves to a {{cssxref("number")}}, a {{cssxref("dimension")}}, a {{cssxref("percentage")}} or a {{cssxref("calc-keyword")}}.

Comment on lines +35 to +36
- if `<calc-sum>`'s numeric value is positive or `0⁺`, return `<calc-sum>`.
- Otherwise, returns `-1 * <calc-sum>`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- if `<calc-sum>`'s numeric value is positive or `0⁺`, return `<calc-sum>`.
- Otherwise, returns `-1 * <calc-sum>`.
- If `<calc-sum>`'s numeric value is positive or `0⁺`, the function returns `<calc-sum>`.
- Otherwise, it returns `-1 * <calc-sum>`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs size/s [PR only] 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants