diff --git a/.vscode/project-words.txt b/.vscode/project-words.txt index 3bcea8226a3e50a..827e5b55f869659 100644 --- a/.vscode/project-words.txt +++ b/.vscode/project-words.txt @@ -23,6 +23,7 @@ hulki i'gyu Kazotetsu Letorey +mathml mdnplay menclose mfenced diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cc0505bf71aee5e..97f7c737e8769c8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -59,7 +59,7 @@ If you are comfortable working with git and GitHub, you can skip ahead to [Contr If you've created a new GitHub account and want to know what to do next, you can choose one of the following ways to manage changes: - [GitHub UI](https://docs.github.com/en/repositories/working-with-files/managing-files) - - This is the easiest way to contribute **small changes** described in [Simple changes](#simple_changes). + This is the easiest way to contribute **small changes** described in [Simple changes](#simple-changes). - [GitHub Desktop](https://docs.github.com/en/get-started/using-github/github-desktop) - A desktop app for managing interaction with GitHub. - [GitHub CLI](https://docs.github.com/en/github-cli/github-cli/about-github-cli) - A command-line wrapper for interacting with GitHub. - [`git`](https://git-scm.com/downloads) - You can use `git` from the command line to interact with GitHub. @@ -339,7 +339,7 @@ Say you want to delete the entire `/en-US/Learn/Accessibility` tree and redirect ### Redirecting a document -If you are [moving a document](#moving-one-or-more-documents) as shown above you don't need to create a redirect. +If you are [moving a document](#moving-documents) as shown above you don't need to create a redirect. However, you may need to do so when fixing a broken link or after [deleting a document](#deleting-a-document) without the `--redirect` flag. You may do this by using the `yarn content add-redirect` command. diff --git a/files/en-us/_redirects.txt b/files/en-us/_redirects.txt index 07119d6d35cedeb..88131a539ce53fc 100644 --- a/files/en-us/_redirects.txt +++ b/files/en-us/_redirects.txt @@ -464,7 +464,7 @@ /en-US/docs/CSS/@page /en-US/docs/Web/CSS/@page /en-US/docs/CSS/@page_rule /en-US/docs/Web/CSS/@page /en-US/docs/CSS/@supports /en-US/docs/Web/CSS/@supports -/en-US/docs/CSS/Adjacent_sibling_selectors /en-US/docs/Web/CSS/Adjacent_sibling_combinator +/en-US/docs/CSS/Adjacent_sibling_selectors /en-US/docs/Web/CSS/Next-sibling_combinator /en-US/docs/CSS/Alias /en-US/docs/Web/CSS/cursor /en-US/docs/CSS/Alternative_style_sheets /en-US/docs/Web/CSS/Alternative_style_sheets /en-US/docs/CSS/At-rule /en-US/docs/Web/CSS/At-rule @@ -499,7 +499,7 @@ /en-US/docs/CSS/Flexbox-redirect-3 /en-US/docs/Web/CSS/CSS_flexible_box_layout/Basic_concepts_of_flexbox /en-US/docs/CSS/Flexible_boxes /en-US/docs/Web/CSS/CSS_flexible_box_layout/Basic_concepts_of_flexbox /en-US/docs/CSS/Flexible_boxes-redirect-1 /en-US/docs/Web/CSS/CSS_flexible_box_layout/Basic_concepts_of_flexbox -/en-US/docs/CSS/General_sibling_selectors /en-US/docs/Web/CSS/General_sibling_combinator +/en-US/docs/CSS/General_sibling_selectors /en-US/docs/Web/CSS/Subsequent-sibling_combinator /en-US/docs/CSS/Getting_Started /en-US/docs/Learn/CSS/First_steps /en-US/docs/CSS/Getting_Started/Boxes /en-US/docs/Learn/CSS/Building_blocks /en-US/docs/CSS/Getting_Started/Cascading_and_inheritance /en-US/docs/Learn/CSS/Building_blocks/Cascade_and_inheritance @@ -953,7 +953,7 @@ /en-US/docs/CSS:@font-face /en-US/docs/Web/CSS/@font-face /en-US/docs/CSS:@import /en-US/docs/Web/CSS/@import /en-US/docs/CSS:@media /en-US/docs/Web/CSS/@media -/en-US/docs/CSS:Adjacent_sibling_selectors /en-US/docs/Web/CSS/Adjacent_sibling_combinator +/en-US/docs/CSS:Adjacent_sibling_selectors /en-US/docs/Web/CSS/Next-sibling_combinator /en-US/docs/CSS:Attribute_selectors /en-US/docs/Web/CSS/Attribute_selectors /en-US/docs/CSS:Aural /en-US/docs/Web/CSS/@media/aural /en-US/docs/CSS:Child_selectors /en-US/docs/Web/CSS/Child_combinator @@ -7777,6 +7777,7 @@ /en-US/docs/Web/API/CanvasRenderingContext2D/mozImageSmoothingEnabled /en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled /en-US/docs/Web/API/CanvasRenderingContext2D/mozTextStyle /en-US/docs/Web/API/CanvasRenderingContext2D/font /en-US/docs/Web/API/Canvas_API/Drawing_graphics_with_canvas /en-US/docs/Web/API/Canvas_API/Tutorial +/en-US/docs/Web/API/Canvas_API/Tutorial/Compositing/Example /en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation /en-US/docs/Web/API/CharacterData.previousElementSibling /en-US/docs/Web/API/CharacterData/previousElementSibling /en-US/docs/Web/API/ChildNode.nextElementSibling /en-US/docs/Web/API/Element/nextElementSibling /en-US/docs/Web/API/ChildNode.remove /en-US/docs/Web/API/Element/remove @@ -9464,6 +9465,7 @@ /en-US/docs/Web/API/RTCOfferAnswerOptions/voiceActivityDetection /en-US/docs/Web/API/RTCPeerConnection/createAnswer /en-US/docs/Web/API/RTCOfferOptions /en-US/docs/Web/API/RTCPeerConnection/createOffer /en-US/docs/Web/API/RTCOfferOptions/iceRestart /en-US/docs/Web/API/RTCPeerConnection/createOffer +/en-US/docs/Web/API/RTCOutboundRtpStreamStats/lastPacketSentTimestamp /en-US/docs/Web/API/RTCOutboundRtpStreamStats /en-US/docs/Web/API/RTCOutboundRtpStreamStats/perDscpPacketsReceived /en-US/docs/Web/API/RTCOutboundRtpStreamStats/perDscpPacketsSent /en-US/docs/Web/API/RTCPeerConnection.addStream /en-US/docs/Web/API/RTCPeerConnection/addStream /en-US/docs/Web/API/RTCPeerConnection.close /en-US/docs/Web/API/RTCPeerConnection/close @@ -11313,7 +11315,8 @@ /en-US/docs/Web/CSS/@viewport/viewport-fit /en-US/docs/Web/CSS /en-US/docs/Web/CSS/@viewport/width /en-US/docs/Web/CSS /en-US/docs/Web/CSS/@viewport/zoom /en-US/docs/Web/CSS -/en-US/docs/Web/CSS/Adjacent_sibling_selectors /en-US/docs/Web/CSS/Adjacent_sibling_combinator +/en-US/docs/Web/CSS/Adjacent_sibling_combinator /en-US/docs/Web/CSS/Next-sibling_combinator +/en-US/docs/Web/CSS/Adjacent_sibling_selectors /en-US/docs/Web/CSS/Next-sibling_combinator /en-US/docs/Web/CSS/Alias /en-US/docs/Web/CSS/cursor /en-US/docs/Web/CSS/All_About_The_Containing_Block /en-US/docs/Web/CSS/Containing_block /en-US/docs/Web/CSS/Aural /en-US/docs/Web/CSS/@media/aural @@ -11438,7 +11441,8 @@ /en-US/docs/Web/CSS/Filter_Effects/Using_filter_effects /en-US/docs/Web/CSS/CSS_filter_effects/Using_filter_effects /en-US/docs/Web/CSS/Filters_Effects /en-US/docs/Web/CSS/CSS_filter_effects /en-US/docs/Web/CSS/Flexbox /en-US/docs/Web/CSS/CSS_flexible_box_layout/Basic_concepts_of_flexbox -/en-US/docs/Web/CSS/General_sibling_selectors /en-US/docs/Web/CSS/General_sibling_combinator +/en-US/docs/Web/CSS/General_sibling_combinator /en-US/docs/Web/CSS/Subsequent-sibling_combinator +/en-US/docs/Web/CSS/General_sibling_selectors /en-US/docs/Web/CSS/Subsequent-sibling_combinator /en-US/docs/Web/CSS/Grouping_selectors /en-US/docs/Web/CSS/Selector_list /en-US/docs/Web/CSS/Interactive /en-US/docs/Web/CSS/@media /en-US/docs/Web/CSS/Layout_cookbook/Recipe:_Media_Objects /en-US/docs/Web/CSS/Layout_cookbook/Media_objects @@ -12031,7 +12035,7 @@ /en-US/docs/Web/Guide/HTML/Canvas_tutorial/Basic_animations /en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations /en-US/docs/Web/Guide/HTML/Canvas_tutorial/Basic_usage /en-US/docs/Web/API/Canvas_API/Tutorial/Basic_usage /en-US/docs/Web/Guide/HTML/Canvas_tutorial/Compositing /en-US/docs/Web/API/Canvas_API/Tutorial/Compositing -/en-US/docs/Web/Guide/HTML/Canvas_tutorial/Compositing/Example /en-US/docs/Web/API/Canvas_API/Tutorial/Compositing/Example +/en-US/docs/Web/Guide/HTML/Canvas_tutorial/Compositing/Example /en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation /en-US/docs/Web/Guide/HTML/Canvas_tutorial/Drawing_shapes /en-US/docs/Web/API/Canvas_API/Tutorial/Drawing_shapes /en-US/docs/Web/Guide/HTML/Canvas_tutorial/Optimizing_canvas /en-US/docs/Web/API/Canvas_API/Tutorial/Optimizing_canvas /en-US/docs/Web/Guide/HTML/Canvas_tutorial/Pixel_manipulation_with_canvas /en-US/docs/Web/API/Canvas_API/Tutorial/Pixel_manipulation_with_canvas @@ -12678,6 +12682,7 @@ /en-US/docs/Web/MathML/Element/mprescripts /en-US/docs/Web/MathML/Element/mmultiscripts /en-US/docs/Web/MathML/Element/none /en-US/docs/Web/MathML/Element/mmultiscripts /en-US/docs/Web/MathML/Fonts/Test /en-US/docs/Web/MathML/Fonts +/en-US/docs/Web/MathML/Global_attributes/mathvariant /en-US/docs/Web/MathML/Element/mi#mathvariant /en-US/docs/Web/MathML/Index /en-US/docs/Web/MathML /en-US/docs/Web/Media/Formats/Guide_to_codecs_for_audio_on_the_web /en-US/docs/Web/Media/Formats/Audio_codecs /en-US/docs/Web/Media/images/aspect_ratio_mapping /en-US/docs/Learn/Performance/Multimedia diff --git a/files/en-us/_wikihistory.json b/files/en-us/_wikihistory.json index 49e7c1e438ede91..65670f7e23a2702 100644 --- a/files/en-us/_wikihistory.json +++ b/files/en-us/_wikihistory.json @@ -24687,10 +24687,6 @@ "trevorh" ] }, - "Web/API/Canvas_API/Tutorial/Compositing/Example": { - "modified": "2019-03-23T23:28:23.382Z", - "contributors": ["brttd", "beaugunderson", "jpmedley", "fscholz", "Sheppy"] - }, "Web/API/Canvas_API/Tutorial/Drawing_shapes": { "modified": "2020-08-05T11:19:13.950Z", "contributors": [ @@ -54608,10 +54604,6 @@ "modified": "2020-10-15T22:17:15.823Z", "contributors": ["Sheppy"] }, - "Web/API/RTCOutboundRtpStreamStats/lastPacketSentTimestamp": { - "modified": "2020-10-15T22:17:16.317Z", - "contributors": ["Sheppy"] - }, "Web/API/RTCOutboundRtpStreamStats/nackCount": { "modified": "2020-10-15T22:17:14.809Z", "contributors": ["Sheppy"] @@ -76818,36 +76810,6 @@ "webinista" ] }, - "Web/CSS/Adjacent_sibling_combinator": { - "modified": "2020-10-15T21:03:44.777Z", - "contributors": [ - "wbamberg", - "cariad", - "mfuji09", - "ExE-Boss", - "fscholz", - "mfluehr", - "KadirTopal", - "erikadoyle", - "jsx", - "Jezer", - "cvrebert", - "Sebastianz", - "teoli", - "jlanus", - "zacharytamas", - "motoxer4533", - "khs", - "FredB", - "Sheppy", - "dhar", - "tregagnon", - "tw2113", - "BYK", - "miken32", - "Wjjohnst" - ] - }, "Web/CSS/Alternative_style_sheets": { "modified": "2020-10-15T21:15:55.661Z", "contributors": [ @@ -78959,31 +78921,6 @@ "Wjjohnst" ] }, - "Web/CSS/General_sibling_combinator": { - "modified": "2020-10-15T21:04:16.746Z", - "contributors": [ - "nko6", - "wbamberg", - "mfuji09", - "ExE-Boss", - "fscholz", - "mfluehr", - "Sheppy", - "erikadoyle", - "mikelew42", - "cvrebert", - "MusikAnimal", - "Sebastianz", - "DanSorahan", - "SphinxKnight", - "FredB", - "teoli", - "ethertank", - "tiffon", - "dhar", - "miken32" - ] - }, "Web/CSS/ID_selectors": { "modified": "2020-12-14T11:20:33.993Z", "contributors": [ @@ -79180,6 +79117,36 @@ "GT" ] }, + "Web/CSS/Next-sibling_combinator": { + "modified": "2020-10-15T21:03:44.777Z", + "contributors": [ + "wbamberg", + "cariad", + "mfuji09", + "ExE-Boss", + "fscholz", + "mfluehr", + "KadirTopal", + "erikadoyle", + "jsx", + "Jezer", + "cvrebert", + "Sebastianz", + "teoli", + "jlanus", + "zacharytamas", + "motoxer4533", + "khs", + "FredB", + "Sheppy", + "dhar", + "tregagnon", + "tw2113", + "BYK", + "miken32", + "Wjjohnst" + ] + }, "Web/CSS/Privacy_and_the_:visited_selector": { "modified": "2020-05-05T20:20:41.094Z", "contributors": [ @@ -79479,6 +79446,31 @@ "jwalker" ] }, + "Web/CSS/Subsequent-sibling_combinator": { + "modified": "2020-10-15T21:04:16.746Z", + "contributors": [ + "nko6", + "wbamberg", + "mfuji09", + "ExE-Boss", + "fscholz", + "mfluehr", + "Sheppy", + "erikadoyle", + "mikelew42", + "cvrebert", + "MusikAnimal", + "Sebastianz", + "DanSorahan", + "SphinxKnight", + "FredB", + "teoli", + "ethertank", + "tiffon", + "dhar", + "miken32" + ] + }, "Web/CSS/Syntax": { "modified": "2020-07-07T12:39:09.357Z", "contributors": [ diff --git a/files/en-us/games/techniques/control_mechanisms/mobile_touch/index.md b/files/en-us/games/techniques/control_mechanisms/mobile_touch/index.md index ff0d1a06fe94f6e..5906380ceedc6fd 100644 --- a/files/en-us/games/techniques/control_mechanisms/mobile_touch/index.md +++ b/files/en-us/games/techniques/control_mechanisms/mobile_touch/index.md @@ -8,7 +8,7 @@ page-type: guide {{NextMenu("Games/Techniques/Control_mechanisms/Desktop_with_mouse_and_keyboard", "Games/Techniques/Control_mechanisms")}} -The future of mobile gaming is definitely web, and many developers choose the [mobile first](/en-US/docs/Web/Apps/Mobile_First) approach in their game development process — in the modern world, this generally also involves implementing touch controls. In this tutorial, we will see how easy it is to implement mobile controls in an HTML game, and enjoy playing on a mobile touch-enabled device. +The future of mobile gaming is definitely web, and many developers choose the [mobile first](/en-US/docs/Glossary/Mobile_First) approach in their game development process — in the modern world, this generally also involves implementing touch controls. In this tutorial, we will see how easy it is to implement mobile controls in an HTML game, and enjoy playing on a mobile touch-enabled device. > **Note:** The game [Captain Rogers: Battle at Andromeda](https://rogers2.enclavegames.com/demo/) is built with Phaser and managing the controls is Phaser-based, but it could also be done in pure JavaScript. The good thing about using Phaser is that it offers helper variables and functions for easier and faster development, but it's entirely up to you which approach you to choose. diff --git a/files/en-us/glossary/accessible_name/index.md b/files/en-us/glossary/accessible_name/index.md index 415998065b524a6..01dea816e3f174a 100644 --- a/files/en-us/glossary/accessible_name/index.md +++ b/files/en-us/glossary/accessible_name/index.md @@ -4,6 +4,8 @@ slug: Glossary/Accessible_name page-type: glossary-definition --- +{{GlossarySidebar}} + An **accessible name** is the name of a user interface element; it is the text associated with an HTML element that provides users of assistive technology with a label for the element. Accessible names convey the purpose or intent of the element. This helps users understand what the element is for and how they can interact with it. In general, accessible names for elements should be unique to a page. This helps users distinguish an element from other elements and helps users identify the element they want to interact with. diff --git a/files/en-us/glossary/base64/index.md b/files/en-us/glossary/base64/index.md index 80cfad2fd4b113a..f421e4436c228d1 100644 --- a/files/en-us/glossary/base64/index.md +++ b/files/en-us/glossary/base64/index.md @@ -52,7 +52,7 @@ function base64ToBytes(base64) { } function bytesToBase64(bytes) { - const binString = Array.from(bytes, (x) => String.fromCodePoint(x)).join(""); + const binString = String.fromCodePoint(...bytes); return btoa(binString); } diff --git a/files/en-us/glossary/binding/index.md b/files/en-us/glossary/binding/index.md index 15a0f7768ae4fbb..31e0dc9df3ecf03 100644 --- a/files/en-us/glossary/binding/index.md +++ b/files/en-us/glossary/binding/index.md @@ -4,6 +4,8 @@ slug: Glossary/Binding page-type: glossary-definition --- +{{GlossarySidebar}} + In programming, a **binding** is an association of an {{glossary("identifier")}} with a value. Not all bindings are {{glossary("variable", "variables")}} — for example, function {{glossary("parameter", "parameters")}} and the binding created by the {{jsxref("Statements/try...catch", "catch (e)")}} block are not "variables" in the strict sense. In addition, some bindings are implicitly created by the language — for example, {{jsxref("Operators/this", "this")}} and [`new.target`](/en-US/docs/Web/JavaScript/Reference/Operators/new.target) in JavaScript. A binding is {{glossary("mutable")}} if it can be re-assigned, and {{glossary("immutable")}} otherwise; this does _not_ mean that the value it holds is immutable. diff --git a/files/en-us/glossary/certificate_authority/index.md b/files/en-us/glossary/certificate_authority/index.md index cfcd6da6a69b353..6cc79662b9b2970 100644 --- a/files/en-us/glossary/certificate_authority/index.md +++ b/files/en-us/glossary/certificate_authority/index.md @@ -10,7 +10,7 @@ A certificate authority (CA) is an organization that {{Glossary("Signature/Secur For a website digital certificate, this information minimally includes the name of the organization that requested the digital certificate (e.g., Mozilla Corporation), the site that it is for (e.g., mozilla.org), and the certificate authority. -Certificate authorities are the part of the Internet [public key infrastructure](https://en.wikipedia.org/wiki/Public_key_infrastructure) that allows browsers to verify website identity and securely connect over SSL (and HTTPS). +Certificate authorities are the part of the Internet [public key infrastructure](https://en.wikipedia.org/wiki/Public_key_infrastructure) that allows browsers to verify website identity and securely connect over TLS (thus HTTPS). > **Note:** Web browsers come preloaded with a list of "root certificates". The browser can use these to reliably check that the website certificate was signed by a certificate authority that "chains back" to the root certificate (i.e. was trusted by the owner of the root certificate or an intermediate CA). Ultimately this process relies on every CA performing adequate identity checks before signing a certificate! diff --git a/files/en-us/glossary/code_splitting/index.md b/files/en-us/glossary/code_splitting/index.md index 6072a5fec6ff879..aa6c424cbe572bf 100644 --- a/files/en-us/glossary/code_splitting/index.md +++ b/files/en-us/glossary/code_splitting/index.md @@ -6,9 +6,9 @@ page-type: glossary-definition {{GlossarySidebar}} -**Code splitting** is the splitting of code into various bundles or components which can then be loaded on demand or in parallel. - -As an application grows in complexity or is maintained, CSS and JavaScripts files or bundles grow in byte size, especially as the number and size of included third-party libraries increases. To prevent the requirement of downloading ginormous files, scripts can be split into multiple smaller files. Then features required at page load can be downloaded immediately with additional scripts being [lazy loaded](/en-US/docs/Glossary/Lazy_load) after the page or application is interactive, thus improving performance. While the total amount of code is the same (and perhaps even a few bytes larger), the amount of code needed during initial load can be reduced. +**Code splitting** is the practice of splitting the code a web application depends on — including its own code and any third-party dependencies — into separate bundles that can be loaded independently of each other. +This allows an application to load only the code it actually needs at a given point in time, and load other bundles on demand. +This approach is used to improve application performance, especially on initial load. Code splitting is a feature supported by bundlers like [Webpack](https://webpack.js.org/) and [Browserify](https://browserify.org/) which can create multiple bundles that can be dynamically loaded at runtime. diff --git a/files/en-us/glossary/css_selector/index.md b/files/en-us/glossary/css_selector/index.md index 055467b9d840c81..770ec5517fde42e 100644 --- a/files/en-us/glossary/css_selector/index.md +++ b/files/en-us/glossary/css_selector/index.md @@ -76,8 +76,8 @@ The resulting page content is styled like this: - Combinators - - [Adjacent sibling selectors](/en-US/docs/Web/CSS/Adjacent_sibling_combinator) `A + B` - - [General sibling selectors](/en-US/docs/Web/CSS/General_sibling_combinator) `A ~ B` + - [Next-sibling selectors](/en-US/docs/Web/CSS/Next-sibling_combinator) `A + B` + - [Subsequent-sibling selectors](/en-US/docs/Web/CSS/Subsequent-sibling_combinator) `A ~ B` - [Child selectors](/en-US/docs/Web/CSS/Child_combinator) `A > B` - [Descendant selectors](/en-US/docs/Web/CSS/Descendant_combinator) `A B` diff --git a/files/en-us/glossary/function/index.md b/files/en-us/glossary/function/index.md index d3767c9dad39fcb..42b0db4f84b1654 100644 --- a/files/en-us/glossary/function/index.md +++ b/files/en-us/glossary/function/index.md @@ -69,7 +69,7 @@ const loop2 = (x) => { }; ``` -An **Immediately Invoked Function Expressions** ({{glossary("IIFE")}}) is a function that is called directly after the function is loaded into the browser's compiler. The way to identify an IIFE is by locating the extra left and right parenthesis at the end of the function's definition. +An **Immediately Invoked Function Expression** ({{glossary("IIFE")}}) is a function that is called directly after the function is loaded into the browser's compiler. The way to identify an IIFE is by locating the extra left and right parenthesis at the end of the function's definition. Function expressions, named or anonymous, can be called immediately. diff --git a/files/en-us/glossary/https/index.md b/files/en-us/glossary/https/index.md index 5c3b70757f2b437..c9bfe8476c3b52c 100644 --- a/files/en-us/glossary/https/index.md +++ b/files/en-us/glossary/https/index.md @@ -6,7 +6,7 @@ page-type: glossary-definition {{GlossarySidebar}} -**HTTPS** (**_HyperText Transfer Protocol Secure_**) is an encrypted version of the {{Glossary("HTTP")}} protocol. It uses {{Glossary("SSL")}} or {{Glossary("TLS")}} to encrypt all communication between a client and a server. This secure connection allows clients to safely exchange sensitive data with a server, such as when performing banking activities or online shopping. +**HTTPS** (**_HyperText Transfer Protocol Secure_**) is an encrypted version of the {{Glossary("HTTP")}} protocol. It uses {{Glossary("TLS")}} to encrypt all communication between a client and a server. This secure connection allows clients to safely exchange sensitive data with a server, such as when performing banking activities or online shopping. ## See also @@ -16,5 +16,5 @@ page-type: glossary-definition - [MDN Web Docs Glossary](/en-US/docs/Glossary) - {{glossary("HTTP")}} - - {{glossary("SSL")}} - {{glossary("TLS")}} + - {{glossary("SSL")}} diff --git a/files/en-us/glossary/https_rr/index.md b/files/en-us/glossary/https_rr/index.md index c8e9f34191a2856..688075c4451944c 100644 --- a/files/en-us/glossary/https_rr/index.md +++ b/files/en-us/glossary/https_rr/index.md @@ -15,5 +15,4 @@ Further, the presence of an _HTTPS RR_ signals that all useful {{Glossary("HTTP" - [Service binding and parameter specification via the DNS (DNS SVCB and HTTPS RRs)](https://datatracker.ietf.org/doc/draft-ietf-dnsop-svcb-https/00/) (Draft IETF specification: draft-ietf-dnsop-svcb-https-00) - [Strict Transport Security vs. HTTPS Resource Records: the showdown](https://emilymstark.com/2020/10/24/strict-transport-security-vs-https-resource-records-the-showdown.html) (Emily M. Stark blog) -- {{glossary("SSL")}} - {{glossary("TLS")}} diff --git a/files/en-us/glossary/json_type_representation/index.md b/files/en-us/glossary/json_type_representation/index.md new file mode 100644 index 000000000000000..ebec5acd9dd42a1 --- /dev/null +++ b/files/en-us/glossary/json_type_representation/index.md @@ -0,0 +1,21 @@ +--- +title: JSON type representation +slug: Glossary/JSON_type_representation +page-type: glossary-definition +--- + +{{GlossarySidebar}} + +{{glossary("JSON")}} is a convenient and widely used format for serializing objects, arrays, numbers, strings, booleans, and null. +[JSON does not support all data types allowed by JavaScript](/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON#javascript_and_json_differences), which means that JavaScript objects that use these incompatible types cannot be directly serialized to JSON. + +The _JSON type representation_ of a JSON-incompatible object is an equivalent JavaScript object with properties encoded such that the information _can_ be serialized to JSON. +This typically has the same properties as the original object for compatible data types, while incompatible properties are converted/serialized to compatible types. +For example, buffer properties in the original object might be [base64url](/en-US/docs/Glossary/Base64)-encoded to strings in the JSON-type representation. + +An object that cannot automatically be serialized to JSON using the [`JSON.stringify()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) method can define an instance method named `toJSON()` that returns the _JSON-type representation_ of the original object. +[`JSON.stringify()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) will then use `toJSON()` to get the object to stringify, instead of the original object. +[`PublicKeyCredential.toJSON()`](/en-US/docs/Web/API/PublicKeyCredential/toJSON) and [`Performance.toJSON()`](/en-US/docs/Web/API/Performance/toJSON) are examples of this approach. + +A JSON string serialized in this way can be deserialized back to the _JSON-type representation_ object using [`JSON.parse()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse). +It is common to provide a converter method, such as {{domxref("PublicKeyCredential.parseCreationOptionsFromJSON_static", "PublicKeyCredential.parseCreationOptionsFromJSON()")}}, to convert the _JSON-type representation_ back to the original object. diff --git a/files/en-us/glossary/openssl/index.md b/files/en-us/glossary/openssl/index.md index 61ce0f96c00df90..b7aa58caf520680 100644 --- a/files/en-us/glossary/openssl/index.md +++ b/files/en-us/glossary/openssl/index.md @@ -6,7 +6,7 @@ page-type: glossary-definition {{GlossarySidebar}} -OpenSSL is an open-source implementation of {{glossary("SSL")}} and {{glossary("TLS")}}. +OpenSSL is an open-source implementation of {{glossary("TLS")}} and {{glossary("SSL")}}. ## See also diff --git a/files/en-us/glossary/prefetch/index.md b/files/en-us/glossary/prefetch/index.md index 5ba5c34feba0fd6..33f70edaad832aa 100644 --- a/files/en-us/glossary/prefetch/index.md +++ b/files/en-us/glossary/prefetch/index.md @@ -6,35 +6,48 @@ page-type: glossary-definition {{GlossarySidebar}} -Prefetching refers to the practice of speculatively fetching resources in the background for pages that the user is _likely_ to navigate to in the near future. +Prefetching refers to the practice of speculatively fetching documents or subresources in the background for pages that the user is _likely_ to navigate to in the near future. This can significantly reduce the load time for the prefetched page if the user does choose to navigate to it. -Prefetching might be used, for example, to fetch the page resources linked by a "Next" button, or a link popup that a user hovers over, or search results. +Prefetching might be used, for example, to fetch the page linked by a "Next" button or its subresources, or a link popup that a user hovers over, or search results. ### Resource prefetching -Resources should be prefetched based on how likely it is that they will be needed in a future navigation. -Browsers can infer this automatically for some resources, such as the current URL in the address bar. +Resources should be prefetched based on how likely it is that they will be needed in a future navigation. Browsers can infer this automatically for some resources, such as the current URL in the address bar. -Browsers will also prefetch content for [``](/en-US/docs/Web/HTML/Element/link) elements with the [`rel="prefetch"`](/en-US/docs/Web/HTML/Attributes/rel/prefetch) attribute. -This allows developers to hint to the browser the likely navigation from the current page. -Note that only these links are prefetched (so `` elements are not), and they are fetched at a lower priority than resources used by the current page, including elements with `fetchPriority="low"`. +This can be done using [``](/en-US/docs/Web/HTML/Attributes/rel/prefetch) (the [Speculation Rules API](/en-US/docs/Web/API/Speculation_Rules_API) only handles document prefetches for navigations): -Prefetching can be used to fetch both HTML and sub-resources for a possible next navigation. A common use case is to have a simple website landing page that fetches more "heavy-weight" resources used by the rest of the site. +```html + +``` + +### Document prefetching + +Developers can provide hints to the browser of navigations that should be prefetched in a couple of different ways: + +[``](/en-US/docs/Web/HTML/Attributes/rel/prefetch): ```html - - + ``` -The fetch request for a `prefetch` operation results in an HTTP Request that includes the HTTP header [`Sec-Purpose: prefetch`](/en-US/docs/Web/HTTP/Headers/Sec-Purpose). A server might use this header to change the cache timeouts for the resources, or perform other special handling. -The request should also include the {{HTTPHeader("Sec-Fetch-Dest")}} header with the value set to `empty`. -The {{HTTPHeader("Accept")}} header in the request should match the value used for normal navigation requests. This allows the browser to find the matching cached resources following navigation. -If a response is returned, it gets cached with the request in the HTTP cache. +[Speculation Rules API](/en-US/docs/Web/API/Speculation_Rules_API) prefetch: + +```html + +``` -> **Note:** Browser vendors are currently aligning around the HTTP headers that are sent, and may use different headers and values. -> The best place to track specification compliance is the [`Sec-Purpose`](/en-US/docs/Web/HTTP/Headers/Sec-Purpose) compatibility table. +The Speculation Rules API handles document prefetches for navigations much better than ``; the former was designed specifically for that purpose whereas the latter has a number of limitations; see [``](/en-US/docs/Web/HTML/Attributes/rel/prefetch) for details. -### DNS Prefetching +### DNS prefetching [DNS prefetching](/en-US/docs/Web/HTML/Attributes/rel/dns-prefetch) resolves domain names in advance, speeding up load times by reducing the time associated with domain lookup at request time. @@ -44,9 +57,6 @@ If a response is returned, it gets cached with the request in the HTTP cache. ## See also -- [Prerender pages in Chrome for instant page navigations](https://developer.chrome.com/blog/prerender-pages/#prerendering-from-the-address-bar) (developer.chrome.com) +- [Speculative loading](/en-US/docs/Web/Performance/Speculative_loading) - {{Glossary("prerender")}} -- [preload](/en-US/docs/Web/HTML/Attributes/rel/preload) -- [dns-prefetch](/en-US/docs/Web/HTML/Attributes/rel/dns-prefetch) -- [page prediction](/en-US/docs/Glossary/Page_prediction) -- [lazy loading](/en-US/docs/Web/Performance/Lazy_loading) +- [Speculation Rules API](/en-US/docs/Web/API/Speculation_Rules_API) diff --git a/files/en-us/glossary/prerender/index.md b/files/en-us/glossary/prerender/index.md index 1c7f2ab75bdcf9b..e1c6c9cdd1772d5 100644 --- a/files/en-us/glossary/prerender/index.md +++ b/files/en-us/glossary/prerender/index.md @@ -6,18 +6,30 @@ page-type: glossary-definition {{GlossarySidebar}} -Prerendering refers to the practice of speculatively [prefetching](/en-US/docs/Glossary/Prefetch) and rendering pages that the user is _likely_ to navigate to in the near future (the browser renders the page in the background in what is effectively an invisible separate tab). +Prerendering refers to the practice of speculatively [prefetching](/en-US/docs/Glossary/Prefetch) and _rendering_ pages that the user is likely to navigate to in the near future (the browser renders the page in the background in what is effectively an invisible separate tab). Prerendering includes downloading a document's subresources and running associated JavaScript. + If the user then chooses to navigate to the page, display of its content can be near instant. -Prerendering might be used, for example, to fetch the page resources linked by a "Next" button, or a link popup that a user hovers over, or the likely page target of the URL being entered into the address bar. +Prerendering might be used, for example, to fetch the page resources linked by a "Next" button, or a link popup that a user hovers over, or the likely page target of the URL being entered into the address bar. The following [speculation rules](/en-US/docs/Web/API/Speculation_Rules_API) could be included in the head of a document to hint to the browser that it should prerender `next.html` and `next2.html`, as either might reasonably be a target of the next navigation: ```html - + ``` Prerendering results in faster display time than prefetching and hence a better user experience, at the cost of more resources being consumed. ## See also -- [Prerender pages in Chrome for instant page navigations](https://developer.chrome.com/blog/prerender-pages/#prerendering-from-the-address-bar) describes Chrome-only features for prerending, such as pre-rendering URLs in the address bar, and use of the proposed speculation rules API. +- [Speculative loading](/en-US/docs/Web/Performance/Speculative_loading) - [prefetch](/en-US/docs/Glossary/Prefetch) +- [Prerender pages in Chrome for instant page navigations](https://developer.chrome.com/blog/prerender-pages/#prerendering-from-the-address-bar) on developer.chrome.com (2023) +- [Speculation Rules API](/en-US/docs/Web/API/Speculation_Rules_API) diff --git a/files/en-us/glossary/rgb/index.md b/files/en-us/glossary/rgb/index.md index c15dc9ee959e6a0..b03ae7c97601591 100644 --- a/files/en-us/glossary/rgb/index.md +++ b/files/en-us/glossary/rgb/index.md @@ -10,11 +10,11 @@ _Red-Green-Blue_ (**RGB**) is a color model that represents colors as mixtures o Alone an RGB value has no meaning. A color model defines how the three components relate to a color space. Graphically, a point in a three-dimensional grid or cube represents a color. Each dimension (or axis) corresponds to a different channel. The RGB color model is then a _cubic_, or _Cartesian_, coordinate system of the underlying color space. -For the web, the underlying color space for an RGB value is _sRGB_ (Standard RGB), and each RGB component is a number between 0 and 255. Float values are supported. +For the web, the underlying color space for an RGB value is _sRGB_ (Standard RGB), and each RGB component is a number between 0 and 255. Note that there are other RGB color spaces, like the _Adobe RGB_ color space, that can represent a wider {{glossary("gamut")}} of color than the _sRGB_ color space. The coordinates in _sRGB_ and _Adobe RGB_ are different. -There are many ways to describe the RGB components of a color. In {{Glossary("CSS")}} they can be represented as a single 24-bit integer in hexadecimal notation (for example, `#add8e6` is light blue), or in functional notation, [`rgb()`](/en-US/docs/Web/CSS/color_value/rgb) as three separate floats between 0 and 255 (for example, `rgb(46 139.5 87)`). In {{Glossary("OpenGL")}}, {{Glossary("WebGL")}}, and {{Glossary("GLSL")}} the red-green-blue components are fractions (floating-point numbers between 0.0 and 1.0), although in the actual color buffer they are typically stored as 8-bit integers. +There are many ways to describe the RGB components of a color. In {{Glossary("CSS")}} they can be represented as a single 24-bit integer in hexadecimal notation (for example, `#add8e6` is light blue), or in functional notation, [`rgb()`](/en-US/docs/Web/CSS/color_value/rgb) as three separate numbers between 0 and 255 (for example, `rgb(46 139.5 87)`). There are also the `srgb`, `srgb-linear`, `a98-rgb`, and `prophoto-rgb` color spaces for the [`color()`](/en-US/docs/Web/CSS/color_value/color) function. RGB is not the only color model that can represent the _sRGB_ color space. Cylindrical coordinate systems like the [`HSL`](/en-US/docs/Web/CSS/color_value/hsl) (_hue-saturation-lightness_) or [`HWB`](/en-US/docs/Web/CSS/color_value/hwb) (_hue-whiteness-blackness_) color models are also used to represent a sRGB color on the web. diff --git a/files/en-us/glossary/time_to_first_byte/index.md b/files/en-us/glossary/time_to_first_byte/index.md index 063e9ea840b60f3..0f746df5669a6ec 100644 --- a/files/en-us/glossary/time_to_first_byte/index.md +++ b/files/en-us/glossary/time_to_first_byte/index.md @@ -6,7 +6,7 @@ page-type: glossary-definition {{GlossarySidebar}} -**Time to First Byte** (TTFB) refers to the time between the browser requesting a page and when it receives the first byte of information from the server. This time includes [DNS](/en-US/docs/Glossary/DNS) lookup and establishing the connection using a [TCP](/en-US/docs/Glossary/TCP) handshake and [SSL](/en-US/docs/Glossary/SSL) handshake if the request is made over [HTTPS](/en-US/docs/Glossary/HTTPS). +**Time to First Byte** (TTFB) refers to the time between the browser requesting a page and when it receives the first byte of information from the server. This time includes [DNS](/en-US/docs/Glossary/DNS) lookup and establishing the connection using a [TCP](/en-US/docs/Glossary/TCP) handshake and [TLS](/en-US/docs/Glossary/TLS) handshake if the request is made over [HTTPS](/en-US/docs/Glossary/HTTPS). TTFB is the time it takes between the start of the request and the start of the response, in milliseconds: diff --git a/files/en-us/glossary/tls/index.md b/files/en-us/glossary/tls/index.md index 41929ef3cd71202..6dc748bc4ae87ab 100644 --- a/files/en-us/glossary/tls/index.md +++ b/files/en-us/glossary/tls/index.md @@ -6,7 +6,7 @@ page-type: glossary-definition {{GlossarySidebar}} -**Transport Layer Security (TLS)**, formerly known as {{Glossary("SSL", "Secure Sockets Layer (SSL)")}}, is a {{Glossary("protocol")}} used by applications to communicate securely across a network, preventing tampering with and eavesdropping on email, web browsing, messaging, and other protocols. Both SSL and TLS are client / server protocols that ensure communication privacy by using cryptographic protocols to provide security over a network. When a server and client communicate using TLS, it ensures that no third party can eavesdrop or tamper with any message. +**Transport Layer Security (TLS)**, formerly known as {{Glossary("SSL", "Secure Sockets Layer (SSL)")}}, is a {{Glossary("protocol")}} used by applications to communicate securely across a network, preventing tampering with and eavesdropping on email, web browsing, messaging, and other protocols. Both TLS and SSL are client / server protocols that ensure communication privacy by using cryptographic protocols to provide security over a network. When a server and client communicate using TLS, it ensures that no third party can eavesdrop or tamper with any message. All modern browsers support the TLS protocol, requiring the server to provide a valid {{Glossary("Digital certificate", "digital certificate")}} confirming its identity in order to establish a secure connection. It is possible for both the client and server to mutually authenticate each other, if both parties provide their own individual digital certificates. diff --git a/files/en-us/glossary/truthy/index.md b/files/en-us/glossary/truthy/index.md index 9c980a631d330b8..d5656a3940c3be2 100644 --- a/files/en-us/glossary/truthy/index.md +++ b/files/en-us/glossary/truthy/index.md @@ -6,7 +6,7 @@ page-type: glossary-definition {{GlossarySidebar}} -In {{Glossary("JavaScript")}}, a **truthy** value is a value that is considered `true` when encountered in a {{Glossary("Boolean")}} context. All values are truthy unless they are defined as {{Glossary("Falsy", "falsy")}}. That is, all values are _truthy_ except `false`, `0`, `-0`, `0n`, `""`, `null`, `undefined`, and `NaN`. +In {{Glossary("JavaScript")}}, a **truthy** value is a value that is considered `true` when encountered in a {{Glossary("Boolean")}} context. All values are truthy unless they are defined as {{Glossary("Falsy", "falsy")}}. That is, all values are _truthy_ except `false`, `0`, `-0`, `0n`, `""`, `null`, `undefined`, `NaN`, and {{domxref("document.all")}}. {{Glossary("JavaScript")}} uses {{Glossary("Type_Coercion", "type coercion")}} in Boolean contexts. diff --git a/files/en-us/learn/css/building_blocks/cascade_and_inheritance/index.md b/files/en-us/learn/css/building_blocks/cascade_and_inheritance/index.md index f9fe145d007b455..0c44d2407ede74d 100644 --- a/files/en-us/learn/css/building_blocks/cascade_and_inheritance/index.md +++ b/files/en-us/learn/css/building_blocks/cascade_and_inheritance/index.md @@ -181,7 +181,7 @@ The amount of specificity a selector has is measured using three different value > **Note:** The universal selector ([`*`](/en-US/docs/Web/CSS/Universal_selectors)), [combinators](/en-US/docs/Learn/CSS/Building_blocks/Selectors/Combinators) (`+`, `>`, `~`, ' '), and specificity adjustment selector ([`:where()`](/en-US/docs/Web/CSS/:where)) along with its parameters, have no effect on specificity. -The negation ([`:not()`](/en-US/docs/Web/CSS/:not)), relational selector ([`:has()`](/en-US/docs/Web/CSS/:has)), and the matches-any ([`:is()`](/en-US/docs/Web/CSS/:is)) pseudo-classes themselves don't have effect on specificity, but their parameters do. The specificity that each contributes to the specificity algorithm is the specificity of the selector in the parameter that has the greatest weight. +The negation ([`:not()`](/en-US/docs/Web/CSS/:not)), relational selector ([`:has()`](/en-US/docs/Web/CSS/:has)), the matches-any ([`:is()`](/en-US/docs/Web/CSS/:is)) pseudo-classes, and [CSS nesting](/en-US/docs/Web/CSS/CSS_nesting/Nesting_and_specificity) themselves don't add to specificity, but their parameters or nested rules do. The specificity weight that each contributes to the specificity algorithm is the specificity weight of the selector in the parameter or nested rule with the greatest weight. The following table shows a few isolated examples to get you in the mood. Try going through these, and make sure you understand why they have the specificity that we have given them. We've not covered selectors in detail yet, but you can find details of each selector on the MDN [selectors reference](/en-US/docs/Web/CSS/CSS_selectors/Selectors_and_combinators). diff --git a/files/en-us/learn/css/building_blocks/cascade_layers/index.md b/files/en-us/learn/css/building_blocks/cascade_layers/index.md index b7cb19d66898c93..4034b3b370c1a5f 100644 --- a/files/en-us/learn/css/building_blocks/cascade_layers/index.md +++ b/files/en-us/learn/css/building_blocks/cascade_layers/index.md @@ -10,7 +10,7 @@ This lesson aims to introduce you to [cascade layers](/en-US/docs/Web/CSS/@layer If you are new to CSS, working through this lesson may seem less relevant immediately and a little more academic than some other parts of the course. However, knowing the basics of what cascade layers are should you encounter them in your projects is helpful. The more you work with CSS, understanding cascade layers and knowing how to leverage their power will save you from a lot of pain managing a code base with CSS from different parties, plugins, and development teams. -Cascade layers are most relevant when you're working with CSS from multiple sources, when there are conflicting CSS selectors and competing specificities, or when you're considering using [`!important`](/en-US/docs/Web/CSS/important). +Cascade layers are most relevant when you're working with CSS from multiple sources when there are conflicting CSS selectors and competing specificities, or when you're considering using [`!important`](/en-US/docs/Web/CSS/important). @@ -29,7 +29,7 @@ Cascade layers are most relevant when you're working with CSS from multiple sour
-For each CSS property applied to an element, there can only be one value. You can view all the property values applied to an element by inspecting the element in your browser's developer tools. The tool's "Styles" panel shows all the property values applied on the element being inspected, along with the matched selector and the CSS source file. The selector from the origin with precedence has its values applied to the matching element. +For each CSS property applied to an element, there can only be one value. You can view all the property values applied to an element by inspecting the element in your browser's developer tools. The tool's "Styles" panel shows all the property values applied to the element being inspected, along with the matched selector and the CSS source file. The selector from the origin with precedence has its values applied to the matching element. In addition to the applied styles, the Styles panel displays crossed-out values that matched the selected element but were not applied due to the cascade, specificity, or source order. Crossed-out styles may come from the same origin with precedence but with lower specificity, or with matching origin and specificity, but were found earlier in the code base. For any applied property value, there may be several declarations crossed out from many different sources. If you see a style crossed out that has a selector with greater specificity it means the value is lacking in origin or importance. @@ -42,9 +42,9 @@ To understand cascade layers, you must understand the CSS cascade well. The sect The C in CSS stands for "Cascading". It is the method by which styles cascade together. The user agent goes through several, very clearly-defined steps to determine the values that get assigned to every property for every element. We will briefly list these steps here and then dig deeper into step 4, cascade layers, which is what you came here to learn: 1. **Relevance:** Find all the declaration blocks with a selector match for each element. -2. **Importance:** Sort rules based on if they are normal or important. Important styles are those that have the [`!important`](/en-US/docs/Web/CSS/important) flag set. +2. **Importance:** Sort rules based on whether they are normal or important. Important styles are those that have the [`!important`](/en-US/docs/Web/CSS/important) flag set. 3. **Origin:** Within each of the two importance buckets, sort rules by author, user, or user-agent origin. -4. **Layers:** Within each of the six origin importance buckets, sort by cascade layer. The layer order for normal declarations is from first layer created to last, followed by unlayered normal styles. This order is inverted for important styles, with unlayered important styles having the lowest precedence. +4. **Layers:** Within each of the six origin importance buckets, sort by cascade layer. The layer order for normal declarations is from the first layer created to the last, followed by unlayered normal styles. This order is inverted for important styles, with unlayered important styles having the lowest precedence. 5. **Specificity:** For competing styles in the origin layer with precedence, sort declarations by [specificity](/en-US/docs/Web/CSS/Specificity). 6. **Order of appearance:** When two selectors in the origin layer with precedence have the same specificity, the property value from the last declared selector with the highest specificity wins. @@ -63,7 +63,7 @@ There are three [cascade origin types](/en-US/docs/Web/CSS/Cascade#origin_types) 7. user-agent important styles 8. styles being transitioned -The "user-agent" is the browser. The "user" is the site visitor. The "author" is you, the developer. Styles declared directly on an element with the {{HTMLElement('style')}} element are author styles. Not including animating and transitioning styles, user-agent normal styles have the lowest precedence; user-agent important styles the highest. +The "user-agent" is the browser. The "user" is the site visitor. The "author" is you, the developer. Styles declared directly on an element with the {{HTMLElement('style')}} element are author styles. Not including animating and transitioning styles, user-agent normal styles have the lowest precedence; user-agent important styles have the highest. ### Origin and specificity @@ -77,7 +77,7 @@ The "competing" selector in the user-agent stylesheet at the time of this writin Origin precedence always wins over selector specificity. If an element property is styled with a normal style declaration in multiple origins, the author style sheet will always override the redundant normal properties declared in a user or user-agent stylesheet. If the style is important, the user-agent stylesheet will always win over author and user styles. Cascade origin precedence ensures specificity conflicts between origins never happen. -One last thing to note before moving on: order of appearance becomes relevant only when competing declarations in the origin of precedence have the same specificity. +One last thing to note before moving on: the order of appearance becomes relevant only when competing declarations in the origin of precedence have the same specificity. ## Overview of cascade layers @@ -103,7 +103,7 @@ Having styles from many sources cascade together, especially from teams that are Specificity conflicts can escalate quickly. A web developer may create a "quick fix" by adding an `!important` flag. While this may feel like an easy solution, it often just moves the specificity war from normal to important declarations. -In the same way that cascade origins provides a balance of power between user, user-agents, and author styles, cascade layers provide a structured way to organize and balance concerns within a single origin, as if each layer in an origin were a sub-origin. A layer can be created for each team, component, and third party, with style precedence based on layer order. +In the same way that cascade origins provide a balance of power between user, user-agents, and author styles, cascade layers provide a structured way to organize and balance concerns within a single origin as if each layer in an origin were a sub-origin. A layer can be created for each team, component, and third party, with style precedence based on layer order. Rules within a layer cascade together, without competing with style rules outside the layer. Cascade layers enable the prioritizing of entire stylesheets over other stylesheets, without having to worry about specificity between these sub-origins. @@ -147,13 +147,13 @@ The [`@layer`](/en-US/docs/Web/CSS/@layer) CSS at-rule is used to declare a casc @layer theme, layout, utilities; ``` -Often times, you will want to have your first line of CSS be this `@layer` declaration (with layer names that make sense for your site, of course) to have full control over layer ordering. +You will often want to have your first line of CSS be this `@layer` declaration (with layer names that make sense for your site, of course) to have full control over layer ordering. -If the above statement is the first line of a site's CSS, the layer order will be `theme`, `layout`, and `utilities`. If some layers were created prior to the above statement, as long as layers with these names don't already exist, these three layers will be created and added to the end of the list of existing layers. However, if a layer with the same name already exists, then the above statement will create only two new layers. For example, if `layout` already existed, only `theme` and `utilities` will be created, but the order of layers in this case will be `layout`, `theme`, and `utilities`. +If the above statement is the first line of a site's CSS, the layer order will be `theme`, `layout`, and `utilities`. If some layers were created prior to the above statement, as long as layers with these names don't already exist, these three layers will be created and added to the end of the list of existing layers. However, if a layer with the same name already exists, then the above statement will create only two new layers. For example, if `layout` already existed, only `theme` and `utilities` will be created, but the order of layers, in this case, will be `layout`, `theme`, and `utilities`. ### The @layer block at-rule for named and anonymous layers -Layers can be created using the block `@layer` at-rule. If an `@layer` at-rule is followed by an identifier and a block of styles, the identifier is used to name the layer and the styles in this at-rule are added to the layer's styles. If a layer with the specified name does not already exist, a new layer will be created. If a layer with the specified name already exists, the styles are added to the previously existing layer. If no name is specified while creating a block of styles using `@layer`, the styles in the at-rule will be added to a new anonymous layer. +Layers can be created using the block `@layer` at-rule. If an `@layer` at-rule is followed by an identifier and a block of styles, the identifier is used to name the layer, and the styles in this at-rule are added to the layer's styles. If a layer with the specified name does not already exist, a new layer will be created. If a layer with the specified name already exists, the styles are added to the previously existing layer. If no name is specified while creating a block of styles using `@layer`, the styles in the at-rule will be added to a new anonymous layer. In the example below, we've used four block and one inline `@layer` at-rules. This CSS does the following in the order listed: @@ -213,7 +213,7 @@ Anonymous layers are created by assigning styles to a layer without naming the l The `@layer` at-rule creates a layer, named or not, or appends styles to a layer if the named layer already exists. We called the first anonymous layer `` and the second ``, this is just so we can explain them. These are actually unnamed layers. There is no way to reference them or add additional styles to them. -All styles declared outside of a layer are joined together in an implicit layer. In the example code above, the first declaration set the `color: #333` property on `body`. This was declared outside of any layer. Normal unlayered declarations take precedence over the normal layered declarations even if the unlayered styles have a lower specificity and come first in the order of appearance. This explains why even though the unlayered CSS was declared first in the code block, the implicit layer containing these unlayered styles takes precedence as if it was the last declared layer. +All styles declared outside of a layer are joined together in an implicit layer. In the example code above, the first declaration set the `color: #333` property on `body`. This was declared outside of any layer. Normal unlayered declarations take precedence over normal layered declarations even if the unlayered styles have a lower specificity and come first in the order of appearance. This explains why even though the unlayered CSS was declared first in the code block, the implicit layer containing these unlayered styles takes precedence as if it was the last declared layer. In the line `@layer theme, layout, utilities;`, in which a series of layers were declared, only the `theme` and `utilities` layers were created; `layout` was already created in the first line. Note that this declaration does not change the order of already created layers. There is currently no way to re-order layers once declared. @@ -229,7 +229,7 @@ If you define a layer using [media](/en-US/docs/Web/CSS/CSS_media_queries/Using_ {{EmbedGHLiveSample("css-examples/learn/layers/media-order.html", '100%', 500)}} -In wide screens, the `site` layer is declared in the first line, meaning `site` has less precedence than `page`. Otherwise, `site` has precedence over `page` because it is declared later on narrow screens. If that doesn't work, try changing the `50em` in the media-query to `10em` or `100em`. +In wide screens, the `site` layer is declared in the first line, meaning `site` has less precedence than `page`. Otherwise, `site` has precedence over `page` because it is declared later on narrow screens. If that doesn't work, try changing the `50em` in the media query to `10em` or `100em`. ### Importing style sheets into named and anonymous layers with @import @@ -269,7 +269,7 @@ Nested layers are layers within a named or an anonymous layer. Each cascade laye ### Advantages of nesting layers -The ability to nest layers enables teams to create cascade layers without worrying about whether other teams will import them into a layer. Similarly, nesting enables you to import third party style sheets into a layer without worrying if that style sheet itself has layers. Because layers can be nested, you don't have to worry about having conflicting layer names between external and internal style sheets. +The ability to nest layers enables teams to create cascade layers without worrying about whether other teams will import them into a layer. Similarly, nesting enables you to import third-party style sheets into a layer without worrying if that style sheet itself has layers. Because layers can be nested, you don't have to worry about having conflicting layer names between external and internal style sheets. ### Creating nested cascade layers @@ -320,20 +320,20 @@ The order of layers determines their order of precedence. Therefore, the order o The above code creates two named layers and one unnamed layer. Let us assume that the three files (`A.css`, `B.css`, and `C.css`) do not contain any additional layers within them. The following list shows where styles declared inside and outside of these files will be sorted from least (1) precedence to highest (10). -1. firstLayer normal styles (`A.css`) -2. secondLayer normal styles (`B.css`) +1. `firstLayer` normal styles (`A.css`) +2. `secondLayer` normal styles (`B.css`) 3. unlayered normal styles (`C.css`) 4. inline normal styles 5. animating styles 6. unlayered important styles (`C.css`) -7. secondLayer important styles (`B.css`) -8. firstLayer important styles (`A.css`) +7. `secondLayer` important styles (`B.css`) +8. `firstLayer` important styles (`A.css`) 9. inline important styles 10. transitioning styles Normal styles declared inside layers receive the lowest priority and are sorted by the order in which the layers were created. Normal styles in the first created layer have the lowest precedence, and normal styles in the layer created last have the highest precedence among the layers. In other words, normal styles declared within `firstLayer` will be overridden by any subsequent stylings on the list if any conflicts exist. -Next up are any styles declared outside of layers. The styles in `C.css` were not imported into a layer and will override any conflicting styles from `firstLayer` and `secondLayer`. Normal styles not declared in a layer always have higher precedence than normal-importance layered styles. +Next up are any styles declared outside of layers. The styles in `C.css` were not imported into a layer and will override any conflicting styles from `firstLayer` and `secondLayer`. Styles not declared in a layer always have higher precedence than styles that _are_ declared inside a layer (with the exception of important styles). Inline styles are declared using the [`style` attribute](/en-US/docs/Web/HTML/Global_attributes/style). Normal styles declared in this way will take precedence over normal styles found in the unlayered and layered style sheets (`firstLayer – A.css`, `secondLayer – B.css`, and `C.css`). @@ -357,9 +357,9 @@ The two styles declared only within layers are `font-style`, with normal importa You can reverse the layer order by changing the first line from `@layer A, B;` to `@layer B, A;`. Try that. Which styles get changed by this, and which stay the same? Why? -The order of layers is set by the order in which the layers appear in your CSS. In our first line, we declared layers without assigning any styles using `@layer` followed by the names of our layers, ending with a semi-colon. Had we omitted this line, the results would have been the same. Why? We assigned styles rules in named @layer blocks in the order A then B. The two layers were created in that first line. Had they not been, these rule blocks would have created them, in that order. +The order of layers is set by the order in which the layers appear in your CSS. In our first line, we declared layers without assigning any styles using `@layer` followed by the names of our layers, ending with a semi-colon. Had we omitted this line, the results would have been the same. Why? We assigned style rules in named `@layer` blocks in the order A then B. The two layers were created in that first line. Had they not been, these rule blocks would have created them, in that order. -We included that first line for two reasons: first, so you could easily edit the line and switch the order, and second, because often times you'll find declaring the order layer up front to be the best practice for your layer order management. +We included that first line for two reasons: first so you could easily edit the line and switch the order, and second because often you'll find declaring the order layer up front to be the best practice for your layer order management. To summarize: diff --git a/files/en-us/learn/css/building_blocks/selectors/combinators/index.md b/files/en-us/learn/css/building_blocks/selectors/combinators/index.md index 7a40c14e539df64..e55dac5dab87d35 100644 --- a/files/en-us/learn/css/building_blocks/selectors/combinators/index.md +++ b/files/en-us/learn/css/building_blocks/selectors/combinators/index.md @@ -64,9 +64,9 @@ If you remove the `>` that designates this as a child combinator, you end up wit {{EmbedGHLiveSample("css-examples/learn/selectors/child.html", '100%', 600)}} -## Adjacent sibling combinator +## Next-sibling combinator -The adjacent sibling selector (`+`) is placed between two CSS selectors. It matches only those elements matched by the second selector that are the next sibling element of the first selector. For example, to select all `` elements that are immediately preceded by a `

` element: +The next-sibling selector (`+`) is placed between two CSS selectors. It matches only those elements matched by the second selector that are the next sibling element of the first selector. For example, to select all `` elements that are immediately preceded by a `

` element: ```css p + img @@ -76,11 +76,13 @@ A common use case is to do something with a paragraph that follows a heading, as If you insert some other element such as a `

` in between the `

` and the `

`, you will find that the paragraph is no longer matched by the selector and so does not get the background and foreground color applied when the element is adjacent. + + {{EmbedGHLiveSample("css-examples/learn/selectors/adjacent.html", '100%', 800)}} -## General sibling combinator +## Subsequent-sibling combinator -If you want to select siblings of an element even if they are not directly adjacent, then you can use the general sibling combinator (`~`). To select all `` elements that come _anywhere_ after `

` elements, we'd do this: +If you want to select siblings of an element even if they are not directly adjacent, then you can use the subsequent-sibling combinator (`~`). To select all `` elements that come _anywhere_ after `

` elements, we'd do this: ```css p ~ img @@ -88,8 +90,40 @@ p ~ img In the example below we are selecting all `

` elements that come after the `

`, and even though there is a `
` in the document as well, the `

` that comes after it is selected. + + {{EmbedGHLiveSample("css-examples/learn/selectors/general.html", '100%', 600)}} +## Creating complex selectors with nesting + +The [CSS nesting module](/en-US/docs/Web/CSS/CSS_nesting/Using_CSS_nesting#combinators) allows you to write nested rules that use combinators to create [complex selectors](/en-US/docs/Web/CSS/CSS_selectors/Selector_structure#complex_selector). + +```css +p { + ~ img { + } +} +/* This is parsed by the browser as */ +p ~ img { +} +``` + +The [`&` nesting selector](/en-US/docs/Web/CSS/Nesting_selector) can also be use to create complex selectors. + +```css +p { + & img { + } +} +/* This is parsed by the browser as */ +p img { +} +``` + + + +{{EmbedGHLiveSample("css-examples/learn/selectors/nesting.html", '100%', 800)}} + ## Using combinators You can combine any of the selectors that we discovered in previous lessons with combinators in order to pick out part of your document. For example, to select list items with a class of "a" which are direct children of a `