Skip to content
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

CSS syntax module and error handling #31076

Merged
merged 43 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
df11dae
New page: CSS syntax error handling
estelle Dec 5, 2023
e9bffa8
deprecate @charset and list as a rule not at-rule
estelle Dec 5, 2023
d5f1733
Define character encoding
estelle Dec 5, 2023
bddc9a2
New page: error handling
estelle Dec 5, 2023
9ff78fc
New page: css syntax module
estelle Dec 5, 2023
1c099d5
delete charset module. move to syntax module
estelle Dec 5, 2023
df627d9
still supported
estelle Dec 5, 2023
9b2da17
table of contents
estelle Dec 6, 2023
bd5f752
better grammar
estelle Dec 6, 2023
10d57b2
better grammar
estelle Dec 6, 2023
2d832cf
better grammar
estelle Dec 6, 2023
3afcdbd
better grammar
estelle Dec 6, 2023
e1424fb
Apply suggestions from code review
estelle Dec 7, 2023
4691893
added a few more notes - prefixes
estelle Dec 7, 2023
245d126
edits per review
estelle Dec 7, 2023
24772a4
change h2 to h3
estelle Dec 9, 2023
4d5c582
Apply suggestions from code review
estelle Dec 13, 2023
71944f1
add guide to module page.
estelle Dec 13, 2023
e287842
change UA to browser
estelle Dec 13, 2023
50c42ce
address https://github.com/mdn/content/pull/30793#discussion_r1421245493
estelle Dec 13, 2023
1ea3167
hyphens to underscores
estelle Dec 13, 2023
e0f68c2
rewrote the at-rule section
estelle Dec 14, 2023
ab85e39
rewrite grammar section
estelle Dec 15, 2023
53a33f3
fixing linter suggestions
dipikabh Dec 15, 2023
debf7a9
final tweaks
estelle Dec 15, 2023
a1c3201
Update files/en-us/web/css/css_syntax/error_handling/index.md
estelle Dec 15, 2023
496af3c
Update files/en-us/web/css/css_syntax/error_handling/index.md
estelle Dec 15, 2023
9d13c82
fix flaws
estelle Dec 15, 2023
30db514
closed comments
estelle Dec 15, 2023
3d99029
borked so fixed
estelle Dec 15, 2023
ee42a50
trailing spaces
estelle Dec 15, 2023
55d3ad9
Update files/en-us/web/css/css_syntax/error_handling/index.md
estelle Dec 15, 2023
84df878
Update files/en-us/web/css/css_syntax/index.md
estelle Dec 15, 2023
94969cd
Small punctuation fixes
chrisdavidmills Dec 18, 2023
362058e
Apply suggestions from code review
estelle Dec 18, 2023
48612a6
header for at-rule
estelle Dec 18, 2023
33c1b0d
updates based on review feedback
estelle Dec 18, 2023
4c2638e
link to display property
estelle Dec 18, 2023
ada256a
Apply suggestions from code review
estelle Dec 18, 2023
1f95522
Update files/en-us/web/css/css_syntax/error_handling/index.md
estelle Dec 18, 2023
d2e6740
Update files/en-us/web/css/css_syntax/index.md
estelle Dec 18, 2023
0cd27ad
Fix broken links
chrisdavidmills Dec 19, 2023
39e7496
typo fix
chrisdavidmills Dec 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11480,6 +11480,7 @@
/en-US/docs/Web/CSS/CSS_User_Interface /en-US/docs/Web/CSS/CSS_basic_user_interface
/en-US/docs/Web/CSS/CSS_Variables /en-US/docs/Web/CSS/CSS_cascading_variables
/en-US/docs/Web/CSS/CSS_Viewport /en-US/docs/Web/CSS
/en-US/docs/Web/CSS/CSS_charsets /en-US/docs/Web/CSS/CSS_syntax
/en-US/docs/Web/CSS/CSS_descriptor_definition /en-US/docs/Web/CSS
/en-US/docs/Web/CSS/CSS_flex-wrap /en-US/docs/Web/CSS/flex-wrap
/en-US/docs/Web/CSS/CSS_grid_layout/Layout_using_line-based_placement /en-US/docs/Web/CSS/CSS_grid_layout/Grid_layout_using_line-based_placement
Expand Down
8 changes: 4 additions & 4 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -77124,10 +77124,6 @@
"modified": "2020-07-07T12:03:44.891Z",
"contributors": ["wbamberg", "mfluehr"]
},
"Web/CSS/CSS_charsets": {
"modified": "2020-10-15T21:38:35.251Z",
"contributors": ["wbamberg", "fscholz", "mfluehr", "Sebastianz", "teoli"]
},
"Web/CSS/CSS_colors": {
"modified": "2020-12-02T11:04:05.642Z",
"contributors": ["peterbe", "wbamberg", "fscholz", "Sheppy", "mfluehr"]
Expand Down Expand Up @@ -78500,6 +78496,10 @@
"modified": "2020-04-27T22:31:21.929Z",
"contributors": ["ExE-Boss", "mfuji09", "rachelandrew"]
},
"Web/CSS/CSS_syntax": {
"modified": "2020-10-15T21:38:35.251Z",
"contributors": ["wbamberg", "fscholz", "mfluehr", "Sebastianz", "teoli"]
},
"Web/CSS/CSS_table": {
"modified": "2020-07-07T12:26:58.542Z",
"contributors": ["wbamberg", "fscholz", "mfluehr", "Sebastianz", "teoli"]
Expand Down
13 changes: 10 additions & 3 deletions files/en-us/web/css/@charset/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,28 @@ browser-compat: css.at-rules.charset

{{CSSRef}}

The **`@charset`** [CSS](/en-US/docs/Web/CSS) [at-rule](/en-US/docs/Web/CSS/At-rule) specifies the character encoding used in the style sheet. It must be the first element in the style sheet and not be preceded by any character; as it is not a [nested statement](/en-US/docs/Web/CSS/Syntax#nested_statements), it cannot be used inside [conditional group at-rules](/en-US/docs/Web/CSS/At-rule#conditional_group_rules). If several `@charset` at-rules are defined, only the first one is used, and it cannot be used inside a `style` attribute on an HTML element or inside the {{ HTMLElement("style") }} element where the character set of the HTML page is relevant.
The **`@charset`** [CSS](/en-US/docs/Web/CSS) rule specifies the character encoding used in the style sheet. Although the first character in `@charset` is the `@` symbol, it is not an [at-rule](/en-US/docs/Web/CSS/At-rule). The [CSS syntax](/en-US/docs/Web/CSS/CSS_syntax) module deprecates this rule, defining it as an unrecognized legacy rule to be dropped when a stylesheet is grammar-checked, but it is [fully supported in all browsers](#browser_compatibility).

The following assertions apply to valid `@charset` usage:

- The `@charset` rule must be the first element in the style sheet and not be preceded by any character.
- `@charset` is not a [nested statement](/en-US/docs/Web/CSS/Syntax#nested_statements) and therefore cannot be used inside [conditional group at-rules](/en-US/docs/Web/CSS/At-rule#conditional_group_rules).
- If several `@charset` at-rules are defined, only the first one is used.
- `@charset` cannot be used inside a `style` attribute on an HTML element or inside the {{ HTMLElement("style") }} element where the character set of the HTML page is relevant.

```css
@charset "utf-8";
```

This at-rule is useful when using non-{{Glossary("ASCII")}} characters in some CSS properties, like {{ cssxref("content") }}.

As there are several ways to define the character encoding of a style sheet, the browser will try the following methods in the following order (and stop as soon as one yields a result) :
As there are several ways to define the character encoding of a style sheet, the browser will try the following methods in the following order (and stop as soon as one yields a result):

1. The value of the [Unicode byte-order](https://en.wikipedia.org/wiki/Byte_order_mark) character placed at the beginning of the file.
2. The value given by the `charset` attribute of the `Content-Type:` HTTP header or the equivalent in the protocol used to serve the style sheet.
3. The `@charset` CSS at-rule.
4. Use the character encoding defined by the referring document: the `charset` attribute of the {{ HTMLElement("link") }} element. This method is obsolete and should not be used.
5. Assume that the document is UTF-8
5. Assume that the document is UTF-8.

## Syntax

Expand Down
24 changes: 0 additions & 24 deletions files/en-us/web/css/css_charsets/index.md

This file was deleted.

Loading