diff --git a/files/en-us/glossary/box_fragment/index.md b/files/en-us/glossary/box_fragment/index.md new file mode 100644 index 000000000000000..c63498af145a32a --- /dev/null +++ b/files/en-us/glossary/box_fragment/index.md @@ -0,0 +1,8 @@ +--- +title: Box fragment +slug: Glossary/box_fragment +page-type: glossary-definition +sidebar: glossarysidebar +--- + +A **box fragment** is an [inline element](/en-US/docs/Glossary/Inline-level_content) that has been split over multiple lines and is controlled by {{cssxref("box-decoration-break")}} CSS property. diff --git a/files/en-us/glossary/decorating_box/index.md b/files/en-us/glossary/decorating_box/index.md new file mode 100644 index 000000000000000..16f119211b124e2 --- /dev/null +++ b/files/en-us/glossary/decorating_box/index.md @@ -0,0 +1,8 @@ +--- +title: Decorating box +slug: Glossary/decorating_box +page-type: glossary-definition +sidebar: glossarysidebar +--- + +A **decorating box** is an [inline element](/en-US/docs/Glossary/Inline-level_content) that has {{cssxref("text-decoration-line")}} CSS property applied to it. diff --git a/files/en-us/glossary/grid/index.md b/files/en-us/glossary/grid/index.md index 0c3f36595eacf5e..309c258aaf8a1ec 100644 --- a/files/en-us/glossary/grid/index.md +++ b/files/en-us/glossary/grid/index.md @@ -11,7 +11,7 @@ The grid that you define using these properties is described as an _explicit gri If you place content outside of this explicit grid, or if you are relying on auto-placement and the grid algorithm needs to create additional row or column {{glossary("grid tracks", "tracks")}} to hold {{glossary("grid cell", "grid cells")}}, then extra tracks will be created in the implicit grid. The _implicit grid_ is the grid created automatically due to content being added outside of the tracks defined. -In the example below I have created an _explicit grid_ of three columns and two rows. The _third_ row on the grid is an _implicit grid_ row track, formed due to their being more than the six items which fill the explicit tracks. +In the example below I have created an _explicit grid_ of three columns and two rows. The _third_ row on the grid is an _implicit grid_ row track, formed due to there being more than the six items which fill the explicit tracks. ## Example diff --git a/files/en-us/web/api/htmlanchorelement/password/index.md b/files/en-us/web/api/htmlanchorelement/password/index.md index e812fa0bc6a5dd7..05bc7b48ff5d7ac 100644 --- a/files/en-us/web/api/htmlanchorelement/password/index.md +++ b/files/en-us/web/api/htmlanchorelement/password/index.md @@ -24,7 +24,7 @@ A string. ```js // An is in the document -const anchor = document.getElementByID("myAnchor"); +const anchor = document.getElementById("myAnchor"); anchor.password; // returns 'flabada' ``` diff --git a/files/en-us/web/api/htmlanchorelement/port/index.md b/files/en-us/web/api/htmlanchorelement/port/index.md index 6b0bed38042d727..852b4587f6ea147 100644 --- a/files/en-us/web/api/htmlanchorelement/port/index.md +++ b/files/en-us/web/api/htmlanchorelement/port/index.md @@ -24,13 +24,13 @@ A string. ```js // An element is in the document -const anchor = document.getElementByID("myAnchor"); +const anchor = document.getElementById("myAnchor"); anchor.port; // returns '' ``` ```js // Another element is in the document -const anchor = document.getElementByID("myAnchor"); +const anchor = document.getElementById("myAnchor"); anchor.port; // Returns:'8888' ``` diff --git a/files/en-us/web/api/htmlanchorelement/username/index.md b/files/en-us/web/api/htmlanchorelement/username/index.md index 8e8c8718f2a04b7..51988a1261c1600 100644 --- a/files/en-us/web/api/htmlanchorelement/username/index.md +++ b/files/en-us/web/api/htmlanchorelement/username/index.md @@ -26,7 +26,7 @@ A string. ```js // An element is in the document -const anchor = document.getElementByID("myAnchor"); +const anchor = document.getElementById("myAnchor"); anchor.username; // returns 'anonymous' ``` diff --git a/files/en-us/web/api/htmlareaelement/password/index.md b/files/en-us/web/api/htmlareaelement/password/index.md index ec76187d8d614b1..9fe2254611b7dd6 100644 --- a/files/en-us/web/api/htmlareaelement/password/index.md +++ b/files/en-us/web/api/htmlareaelement/password/index.md @@ -24,7 +24,7 @@ A string. ```js // An is in the document -const area = document.getElementByID("myArea"); +const area = document.getElementById("myArea"); area.password; // returns 'flabada' ``` diff --git a/files/en-us/web/api/htmlareaelement/port/index.md b/files/en-us/web/api/htmlareaelement/port/index.md index 5426e70500141d8..f139c13e28fa1d5 100644 --- a/files/en-us/web/api/htmlareaelement/port/index.md +++ b/files/en-us/web/api/htmlareaelement/port/index.md @@ -24,13 +24,13 @@ A string. ```js // An element is in the document -const area = document.getElementByID("myArea"); +const area = document.getElementById("myArea"); area.port; // Returns '' ``` ```js // Another element is in the document -const area = document.getElementByID("myArea"); +const area = document.getElementById("myArea"); area.port; // Returns:'8888' ``` diff --git a/files/en-us/web/api/htmlareaelement/username/index.md b/files/en-us/web/api/htmlareaelement/username/index.md index 102224cf76db283..3225337cb1cfad4 100644 --- a/files/en-us/web/api/htmlareaelement/username/index.md +++ b/files/en-us/web/api/htmlareaelement/username/index.md @@ -26,7 +26,7 @@ A string. ```js // An element is in the document -const area = document.getElementByID("myArea"); +const area = document.getElementById("myArea"); area.username; // returns 'anonymous' ``` diff --git a/files/en-us/web/css/guides/box_model/introduction/index.md b/files/en-us/web/css/guides/box_model/introduction/index.md index 19bf143f6ad0a56..551670ec7fb6893 100644 --- a/files/en-us/web/css/guides/box_model/introduction/index.md +++ b/files/en-us/web/css/guides/box_model/introduction/index.md @@ -28,7 +28,7 @@ The thickness of the padding is determined by the {{cssxref("padding-top")}}, {{ The **border area**, bounded by the border edge, extends the padding area to include the element's borders. Its dimensions are the _border-box width_ and the _border-box height_. -The thickness of the borders are determined by the {{cssxref("border-width")}} and shorthand {{cssxref("border")}} properties. If the {{cssxref("box-sizing")}} property is set to `border-box`, the border area's size can be explicitly defined with the {{cssxref("width")}}, {{cssxref("min-width")}}, {{cssxref("max-width")}}, {{ cssxref("height") }}, {{cssxref("min-height")}}, and {{cssxref("max-height")}} properties. When there is a background ({{cssxref("background-color")}} or {{cssxref("background-image")}}) set on a box, it extends to the outer edge of the border (i.e., extends underneath the border in z-ordering). This default behavior can be altered with the {{cssxref("background-clip")}} CSS property. +The thickness of the borders is determined by the {{cssxref("border-width")}} and shorthand {{cssxref("border")}} properties. If the {{cssxref("box-sizing")}} property is set to `border-box`, the border area's size can be explicitly defined with the {{cssxref("width")}}, {{cssxref("min-width")}}, {{cssxref("max-width")}}, {{ cssxref("height") }}, {{cssxref("min-height")}}, and {{cssxref("max-height")}} properties. When there is a background ({{cssxref("background-color")}} or {{cssxref("background-image")}}) set on a box, it extends to the outer edge of the border (i.e., extends underneath the border in z-ordering). This default behavior can be altered with the {{cssxref("background-clip")}} CSS property. ## Margin area diff --git a/files/en-us/web/css/guides/cascade/specificity/index.md b/files/en-us/web/css/guides/cascade/specificity/index.md index 497c4f6591e5bb6..e67f49ed0a6ae63 100644 --- a/files/en-us/web/css/guides/cascade/specificity/index.md +++ b/files/en-us/web/css/guides/cascade/specificity/index.md @@ -179,7 +179,7 @@ p, } ``` -In the above code block the complex selector `p, #fakeId` the specificity is taken from `#fakeId` and also the `span`, so this create a specificity of `1-0-1` for both `p span` and `#fakeId span`. This is the equivalent specificity as the `:is(p, #fakeId) span` selector. +In the above code block the complex selector `p, #fakeId` the specificity is taken from `#fakeId` and also the `span`, so this creates a specificity of `1-0-1` for both `p span` and `#fakeId span`. This is the equivalent specificity as the `:is(p, #fakeId) span` selector. Generally, you want to keep specificity down to a minimum, but if you need to increase an element's specificity for a particular reason, these three pseudo-classes can help. @@ -349,12 +349,12 @@ To remove the perceived need for `!important`, you can do one of the following: All these methods are covered in preceding sections. -If you're unable to remove `!important` flags from an authors style sheet, the only solution to overriding the important styles is by using `!important`. Creating a [cascade layer](/en-US/docs/Web/CSS/Reference/At-rules/@layer) of important declaration overrides is an excellent solution. Two ways of doing this include: +If you're unable to remove `!important` flags from an author's style sheet, the only solution to overriding the important styles is by using `!important`. Creating a [cascade layer](/en-US/docs/Web/CSS/Reference/At-rules/@layer) of important declaration overrides is an excellent solution. Two ways of doing this include: #### Method 1 1. Create a separate, short style sheet containing only important declarations specifically overriding any important declarations you were unable to remove. -2. Import this stylesheet as the first import in your CSS using `layer()`, including the `@import` statement, before linking to other stylesheets. This is to ensure that the important overrides is imported as the first layer. +2. Import this stylesheet as the first import in your CSS using `layer()`, including the `@import` statement, before linking to other stylesheets. This is to ensure that the important overrides are imported as the first layer. ```css @import "importantOverrides.css" layer(); diff --git a/files/en-us/web/css/guides/grid_layout/index.md b/files/en-us/web/css/guides/grid_layout/index.md index 0d6ce59403c0ff7..1e98f1325820774 100644 --- a/files/en-us/web/css/guides/grid_layout/index.md +++ b/files/en-us/web/css/guides/grid_layout/index.md @@ -75,7 +75,7 @@ The example shows a three-column track grid with new rows created at a minimum o {{EmbedLiveSample("Grid_layout_in_action", "100%", "460")}} -This sample animation uses {{cssxref("display")}}, {{cssxref("grid-template-columns")}}, {{cssxref("grid-template-rows")}}, and {{cssxref("gap")}} to create the grid, and {{cssxref("grid-column")}} and {{cssxref("grid-row")}} to position items within in the grid. To view and edit the HTML and CSS used, click the 'Play' at the top right of the example. +This sample animation uses {{cssxref("display")}}, {{cssxref("grid-template-columns")}}, {{cssxref("grid-template-rows")}}, and {{cssxref("gap")}} to create the grid, and {{cssxref("grid-column")}} and {{cssxref("grid-row")}} to position items within the grid. To view and edit the HTML and CSS used, click the 'Play' at the top right of the example. ## Reference @@ -135,7 +135,7 @@ This sample animation uses {{cssxref("display")}}, {{cssxref("grid-template-colu - : Placing grid items using named template areas. - [Grid layout using named grid lines](/en-US/docs/Web/CSS/Guides/Grid_layout/Named_grid_lines) - - : Combining names and track sizes; placing grid items by defining named grid lined and template areas. + - : Combining names and track sizes; placing grid items by defining named grid lines and template areas. - [Auto-placement in grid layout](/en-US/docs/Web/CSS/Guides/Grid_layout/Auto-placement) - : How grid positions items that don't have any placement properties declared. diff --git a/files/en-us/web/css/guides/selectors/using__colon_target/index.md b/files/en-us/web/css/guides/selectors/using__colon_target/index.md index b4127412124390c..77fa2c5140cd37c 100644 --- a/files/en-us/web/css/guides/selectors/using__colon_target/index.md +++ b/files/en-us/web/css/guides/selectors/using__colon_target/index.md @@ -12,7 +12,7 @@ When a URL points at a specific piece of a document using a [URL fragment identi The [pseudo-class](/en-US/docs/Web/CSS/Reference/Selectors/Pseudo-classes) {{cssxref(":target")}} is used to style the target element of the document identified using the URL fragment identifier. For example, the URL `https://developer.mozilla.org/en-US/docs/Web/CSS#reference` contains the fragment identifier `#reference`. In HTML, identifiers are found as the values of either `id` or `name` attributes, since the two share the same namespace. Thus, the example URL would point to the element that has the id `reference` in that document. -To style any `h2` element that is the target of a URL, while not effecting any other kind of element to get a target style, use the `:target` pseudo-class with the [type selector](/en-US/docs/Web/CSS/Reference/Selectors/Type_selectors): +To style any `h2` element that is the target of a URL, while not affecting any other kind of element to get a target style, use the `:target` pseudo-class with the [type selector](/en-US/docs/Web/CSS/Reference/Selectors/Type_selectors): ```css h2:target { diff --git a/files/en-us/web/css/reference/properties/column-rule-inset-cap-end/index.md b/files/en-us/web/css/reference/properties/column-rule-inset-cap-end/index.md index 0d4415da18015c9..617c4a589098e69 100644 --- a/files/en-us/web/css/reference/properties/column-rule-inset-cap-end/index.md +++ b/files/en-us/web/css/reference/properties/column-rule-inset-cap-end/index.md @@ -11,20 +11,20 @@ sidebar: cssref {{SeeCompatTable}} -The **`column-rule-inset-cap-end`** [CSS](/en-US/docs/Web/CSS) property can be used to offset the bottom of column rule segment [cap endpoints](#understanding_cap_end) at the container's content end edge, and cap endpoints where no rule segments intersect. +The **`column-rule-inset-cap-end`** [CSS](/en-US/docs/Web/CSS) property can be used to offset the bottom of column rule segment [cap endpoints](#understanding_cap_end) at the container's end edge, and cap endpoints where no rule segments intersect. {{InteractiveExample("CSS Demo: rule")}} ```css interactive-example-choice -column-rule-inset-cap-end: 0; +column-rule-inset-cap-end: -20px; ``` ```css interactive-example-choice -column-rule-inset-cap-end: 1em; +column-rule-inset-cap-end: 0; ``` ```css interactive-example-choice -column-rule-inset-cap-end: -20px; +column-rule-inset-cap-end: 1em; ``` ```css interactive-example-choice @@ -68,6 +68,7 @@ column-rule-inset-cap-end: overlap-join; display: grid; grid-template-columns: repeat(7, 1fr); rule: solid thick magenta; + column-rule-color: rebeccapurple; gap: 1em; rule-overlap: column-over-row; rule-visibility-items: between; @@ -140,13 +141,13 @@ Length `column-rule-inset-cap-end` values inset segments by the specified value The `column-rule-inset-cap-end` property is a constituent property of several [shorthand properties](/en-US/docs/Web/CSS/Guides/Cascade/Shorthand_properties): -- To set the inset of the start and end caps, the `column-rule-inset-cap-end` property, along with the {{cssxref("column-rule-inset-cap-start")}} property, can be set using the {{cssxref("column-rule-inset-cap")}} shorthand. +- To inset the start and end caps, the `column-rule-inset-cap-end` property, along with the {{cssxref("column-rule-inset-cap-start")}} property, can be set using the {{cssxref("column-rule-inset-cap")}} shorthand. -- To set the ends of all column segments, the `column-rule-inset-cap-end` property, along with the {{cssxref("column-rule-inset-junction-end")}} property, can be set using the {{cssxref("column-rule-inset-end")}} shorthand. +- To inset the ends of all column segments, the `column-rule-inset-cap-end` property, along with the {{cssxref("column-rule-inset-junction-end")}} property, can be set using the {{cssxref("column-rule-inset-end")}} shorthand. -- To set the same values for row and column cap and junction endpoints, the `column-rule-inset-end` property, along with the {{cssxref("row-rule-inset-end")}} property, can be set using the {{cssxref("rule-inset-end")}} shorthand. +- To inset all row and column cap and junction endpoints, the `column-rule-inset-end` property, along with the {{cssxref("row-rule-inset-end")}} property, can be set using the {{cssxref("rule-inset-end")}} shorthand. -All of these shorthand properties, along with their `-start`, `-junction`, and `row-` equivalents, can be set using the {{cssxref("rule-inset")}} shorthand. +All segment endpoints, including this property's `-start`, `-junction`, and `row-` equivalents, can be set using the {{cssxref("rule-inset")}} shorthand. ### Understanding cap end @@ -246,6 +247,18 @@ li { width: 100%; box-sizing: border-box; } + +@layer no-support { + @supports not (column-rule-inset-cap-end: 16px) { + body::before { + content: "Your browser doesn't support the column-rule-inset-cap-end property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} ``` ```css hidden live-sample___percents @@ -295,15 +308,17 @@ visibility.addEventListener("change", () => { {{EmbedLiveSample("caps", "", "300")}} -Setting `16px` insets the end of all the column rules by 16px. If `0px` is set, the end of the column rules will align with the end of the container. This is the default. Setting `-32px` outsets the segments by `32px`, with the lines being drawn `32px` past the end edge of the container. As column rules don't impact the box model, these lines have no impact on the layout of the container or the rest of the content. +Change the inset. If `0px` is set, the end of the column rules will align with the end of the container. This is the default. Setting `-32px` outsets the segments by `32px`, with the lines being drawn `32px` past the end edge of the container. As column rules don't impact the box model, these lines have no impact on the layout of the container or the rest of the content. -Select `around` as the `rule-visibility-items` value. This value paints rules in a gap segment if at least one of the two adjacent areas is occupied by an item. The double line-style column rules, which appear when the `rule-visibility-items` is set to `around` (and `between`) do not end in a cap endpoint. The last two column rules end at interior gaps where row rule segments are present, so these column segments are not cap segment endpoints, and are therefore not affected by the `column-rule-inset-cap-end` property. +Select `around` as the `rule-visibility-items` value. This value paints rules in a gap segment if at least one of the two adjacent areas is occupied by an item. The double line-style column rules, which appear when the `rule-visibility-items` property is set to `around` do not end in a cap endpoint. The last two column rules end at interior gaps where row rule segments are present, so these column segments are not cap segment endpoints. Therefore, the `column-rule-inset-cap-end` property does not affect those segment endpoints. Select `between` as the `rule-visibility-items` value, which paints rules in gap segments only if both adjacent areas are occupied by an item. The last row rule in the second row gutter ends at the third column gap. The third column rule ends at an interior gap where a row rule segment is present, so this column segment is not a cap segment endpoint and is not affected by the `column-rule-inset-cap-end` property. The last two column rules, however, end at interior gaps where no other rule segments are present, so these column segments are cap segment endpoints and therefore are affected by the `column-rule-inset-cap-end` property. ### Understanding percentage values -What length a percentage value is relative to depends on the endpoint's location. Interior endpoint percentage values are relative to the gap width at the cap endpoint, so relative to the {{cssxref("row-gap")}} if abutting a rule gap. In this demonstration, these endpoints are denoted by the inset, dark and light, line style. If the cap segment endpoint is at the container's edge, the percentage is relative to `0`, so it always computes to `0` (which is why only the `between` value has an effect). +The length a percentage value is relative to depends on the endpoint location. Interior endpoint percentage values are relative to the width of the gap at the cap endpoint, so relative to the {{cssxref("row-gap")}} if abutting a rule gap, and `0` at the bottom edge of the container. + +In this demonstration, these endpoints are denoted by the inset, dark and light, line style. If the cap segment endpoint is at the container's edge, the percentage is relative to `0`, so it always computes to `0` (which is why only the `between` value has an effect). {{EmbedLiveSample("percents", "", "300")}} @@ -429,6 +444,17 @@ output { p { margin-top: 2.5em; } +@layer no-support { + @supports not (column-rule-inset-cap-end: 16px) { + body::before { + content: "Your browser doesn't support the column-rule-inset-cap-end property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} ``` ```js hidden live-sample___basic diff --git a/files/en-us/web/css/reference/properties/column-rule-inset-cap-start/index.md b/files/en-us/web/css/reference/properties/column-rule-inset-cap-start/index.md new file mode 100644 index 000000000000000..be0ea1f51808b5d --- /dev/null +++ b/files/en-us/web/css/reference/properties/column-rule-inset-cap-start/index.md @@ -0,0 +1,499 @@ +--- +title: "`column-rule-inset-cap-start` CSS property" +short-title: column-rule-inset-cap-start +slug: Web/CSS/Reference/Properties/column-rule-inset-cap-start +page-type: css-property +status: + - experimental +browser-compat: css.properties.column-rule-inset-cap-start +sidebar: cssref +--- + +{{SeeCompatTable}} + +The **`column-rule-inset-cap-start`** [CSS](/en-US/docs/Web/CSS) property can be used to offset the top of column rule segment [cap endpoints](#understanding_cap_end) at the container's start edge, and cap endpoints where no rule segments intersect. + +{{InteractiveExample("CSS Demo: rule")}} + + + +```css interactive-example-choice +column-rule-inset-cap-start: -20px; +``` + +```css interactive-example-choice +column-rule-inset-cap-start: 0; +``` + +```css interactive-example-choice +column-rule-inset-cap-start: 1em; +``` + +```css interactive-example-choice +column-rule-inset-cap-start: 100%; +``` + +```css interactive-example-choice +column-rule-inset-cap-start: overlap-join; +``` + +```html interactive-example +
+
+ A + B + C + D + E + F + G + H + I + J + K + L + M + N + O + P + Q + + Y + Z + ! +
+
+``` + +```css interactive-example +#example-element { + display: grid; + grid-template-columns: repeat(7, 1fr); + rule: solid thick magenta; + column-rule-color: rebeccapurple; + gap: 1em; + rule-overlap: column-over-row; + rule-visibility-items: between; + border: 1px solid rebeccapurple; + overflow: visible; + margin: 1em; +} +#example-element i { + padding: 8px; + border: 1px dashed; +} +#y { + grid-column: 4 / 5; + grid-row: 4 / 5; +} +#z { + grid-column: 5 / 6; + grid-row: 4 / 5; +} +#bang { + grid-column: 6 / 7; + grid-row: 4 / 5; +} +``` + +## Syntax + +```css +/* Keywords */ +column-rule-inset-cap-start: overlap-join; + +/* values */ +column-rule-inset-cap-start: 0; +column-rule-inset-cap-start: 1em; +column-rule-inset-cap-start: -5px; +column-rule-inset-cap-start: -25%; + +/* Global values */ +column-rule-inset-cap-start: inherit; +column-rule-inset-cap-start: initial; +column-rule-inset-cap-start: revert; +column-rule-inset-cap-start: revert-layer; +column-rule-inset-cap-start: unset; +``` + +### Values + +This property is specified as a single value from the following list: + +- `overlap-join` + - : Resolves to `0`. +- {{cssxref("length-percentage")}} + - : Specifies the size of the inset. Percentage values are relative to the cap endpoint, which is either the width of the `row-gap` or `0`. + +## Description + +The `column-rule-inset-cap-start` property can be used to inset the start edge of [cap segment endpoints](#understanding_cap_end). The default value is `0`, which is the same as `overlap-join`. Positive values reduce the segment size, while negative values increase it. + +Column rules are painted within a column gap as one or more segments, with segments occurring between: + +- Adjacent columns in CSS grid layouts. +- Flex items or flex lines in flex layouts, depending on the `flex-direction`. +- Columns in multi-col layouts. + +Length `column-rule-inset-cap-start` values inset segments by the specified value — for both interior and end edge cap segments. Negative length values create an outset, with end edge cap segments extending beyond the container's start edge. + +[Percentage values](#understanding_percentage_values) for interior segments are relative to the size of the {{cssxref("row-gap")}}. For start edge cap segments, percentage values are relative to `0`, so percentage values never cause cap segment endpoints at the container's start edge to extend above the container. + +The `column-rule-inset-cap-start` property is a constituent property of several [shorthand properties](/en-US/docs/Web/CSS/Guides/Cascade/Shorthand_properties): + +- To inset both start and end caps, the `column-rule-inset-cap-start` property, along with the {{cssxref("column-rule-inset-cap-end")}} property, can be set using the {{cssxref("column-rule-inset-cap")}} shorthand. + +- To inset the start of all column segment endpoints, the `column-rule-inset-cap-start` property, along with the {{cssxref("column-rule-inset-junction-end")}} property, can be set using the {{cssxref("column-rule-inset-end")}} shorthand. + +All segment endpoints, including this property's `-end`, `-junction`, and `row-` equivalents, can be set using the {{cssxref("rule-inset")}} shorthand. + +### Understanding cap start + +A _cap segment endpoint_ is any segment endpoint that is not a junction segment endpoint. This includes endpoints at the container's content edges, as well as endpoints at a gap junction where no other rule segments are present. + +The `column-rule-inset-cap-start` property controls the inset of the top edge of column cap segment endpoints, allowing the segments to be shrunk or extended. In other words, the property can be used to shrink or extend the top edge of column rule segments that abut the top edge of the container and the segments whose top ends at an interior gaps where no other column or row rule segments are present. + +Column cap segment endpoints are not affected by the value of the `column-rule-break` property value settings, which only control junction segment breaks. They are, however, affected by the {{cssxref("rule-visibility-items")}} properties, which define whether column- and row-rule segments are painted in gaps adjacent to empty areas. + +Column cap segment endpoints only exist at the edge of the container and at interior gaps where no other column or row rule segments are present, whether segments are painted (or would otherwise be painted if the `rule` were set to a visible value), impacts which column segments are cap start segments. + +In the following demonstration, the top of the column rule segments with a solid line style start in a cap endpoint. With `column-rule-inset-cap-start: 16px` set, all the column cap segments at the top edge of the container are all inset by `16px`. Change the inset `` value to better visualize which segments start with cap segment endpoints. + +```html hidden live-sample___caps live-sample___percents +
    +
  • 1
  • +
  • 2
  • +
  • 3
  • +
  • 4
  • +
  • 5
  • +
  • 6
  • +
  • 7
  • +
  • 8
  • +
  • 9
  • +
  • 10
  • +
  • 11
  • +
  • 12
  • +
  • 13
  • +
  • 14
  • +
  • 15
  • +
  • 16
  • +
  • 17
  • +
+ +

+ +

+``` + +```html hidden live-sample___caps +

+ + 16px +

+``` + +```html hidden live-sample___percents +

+ + 100% +

+``` + +```css hidden live-sample___caps live-sample___percents +ul { + display: grid; + grid-template-columns: repeat(6, auto); + list-style-type: none; + gap: 20px; + column-rule: 10px solid olive; + row-rule: 10px solid palegoldenrod; + rule-overlap: column-over-row; + rule-visibility-items: normal; + rule-break: intersection; + column-rule-inset-cap-start: 16px; + + border: 1px solid; +} +ul { + place-items: center; + width: 95vw; + padding: 0; +} +li { + text-align: center; + font-family: sans-serif; + background-color: #ededed; + padding: 1em; + width: 100%; + box-sizing: border-box; +} +li:nth-of-type(n + 9) { + grid-row: 3 / 4; +} +li:nth-of-type(n + 12) { + grid-row: 4 / 5; +} +li:nth-of-type(10) { + grid-column: 5/6; +} +li:nth-of-type(11) { + grid-column: 6/7; +} + +@layer no-support { + @supports not (column-rule-inset-cap-start: 16px) { + body::before { + content: "Your browser doesn't support the column-rule-inset-cap-start property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} +``` + +```css hidden live-sample___percents +ul { + column-rule-inset-cap-start: 100%; +} +``` + +```js hidden live-sample___caps live-sample___percents +const inset = document.getElementById("inset"); +const visibility = document.getElementById("visibility"); +const ul = document.getElementById("ul"); +const output = document.getElementById("o"); + +inset.addEventListener("input", () => { + output.innerText = + ul.style.columnRuleInsetCapStart = `${inset.value}${inset.dataset["unit"]}`; +}); +``` + +```js hidden live-sample___caps live-sample___percents +visibility.addEventListener("change", () => { + ul.style.ruleVisibilityItems = `${visibility.value}`; + if (visibility.value == "between") { + ul.style.columnRuleStyle = "solid, repeat(2, double)"; + } else { + ul.style.columnRuleStyle = "solid"; + } +}); +``` + +{{EmbedLiveSample("caps", "", "400")}} + +Change the inset. If `0px` is set, the start of the column rules will align with the start of the container. This is the default. Setting `-32px` outsets the segments by `32px`, with the lines being drawn `32px` past the start edge of the container. As column rules don't impact the box model, these lines have no impact on the layout of the container or the rest of the content. + +Select `between` as the `rule-visibility-items` value. This value paints rules in a gap segment only if the two adjacent areas are occupied by items. Change the value of the inset while observing the three column rules with a double line style: in addition to having a cap endpoint at the start edge of the container, these rules have an additional cap endpoint. They each have column rule segments that start at interior gaps where no row rule segments are present, so these column segments are also cap segment endpoints, and are affected by the `column-rule-inset-cap-start` property. + +Selecting `around` as the `rule-visibility-items` value paints rules in a gap segment as long as one adjacent area is occupied by an item. In these cases, there is a row rule segment at the top end of the endpoint segments of the interior gaps. The starts of these segments are junction (not cap) segment endpoints and are not affected by the `column-rule-inset-cap-start` property. The inset of these column segments that start at an interior gap junction can be controlled by the {{cssxref("column-rule-inset-junction-start")}} property. + +### Understanding percentage values + +The length a percentage value is relative to depends on the endpoint location. Interior endpoint percentage values are relative to the width of the gap at the cap endpoint, so relative to the {{cssxref("row-gap")}} if abutting a rule gap, and `0` at the top edge of the container. + +This example isn't broken; all the cap segments start at the container's edge, so all the insets are `0` by default. + +{{EmbedLiveSample("percents", "", "400")}} + +If you select `around` as the `rule-visibility-items` value, again, none of the segments will be inset. Percentage inset values for the column segments that start at container edge all resolve to `0`. The start edge of column segments that start at interior gaps don't and have a segment drawn above start at intersections where row rule segments are present; they don't start with a cap segment endpoint, so their insets are defined by the `column-rule-inset-junction-start` property instead. + +Select `between` as the `rule-visibility-items` value. The column rules that have two cap start segments have their line-style set to `double`. As before, each has a column rule segment that starts at interior gaps where no other rule segments are present. For these, the percentage offset is relative to the size of the {{cssxref("row-gap")}} width, which in this case is `20px`. + +Setting `100%` insets the start of the cap segments by `20px`. Setting `-200%` will outset these segments by `40px`, with the lines being drawn through the `20px` gap, with `20px` protruding into the row above the items. If the negative value was larger than the combined heights of the first row and the row gap, the rule would protrude above the container's start edge. + +## Formal definition + +{{cssinfo}} + +## Formal syntax + +{{csssyntax}} + +## Examples + +### Basic usage + +This example demonstrates setting `column-rule-inset-cap-start` to inset the start edge of cap segments on flex containers. + +#### HTML + +```html +

Insetting cap column rule endpoints

+
+
+

flex-direction: row

+
+
+
+
+
+
+
+
+
+
+
+

flex-direction: column

+
+
+
+
+
+
+
+
+
+
+
+``` + +```html hidden +

+ + 16px +

+``` + +#### CSS + +We use the {{cssxref("display")}} property to turn the `.flexbox` elements into flex containers. We balance the items into three flex lines using {{cssxref("flex-wrap")}} and {{cssxref("flex-line-count")}}. We define a light blue {{cssxref("rule")}} to be painted in both row and column gaps, then overwrite the {{cssxref("column-rule-color")}}, setting darker `blue` column gap decorations. Finally, we set the `column-rule-inset-cap-start` to `16px`. + +```css +.flexbox { + display: flex; + flex-wrap: balance; + flex-line-count: 3; + gap: 20px; + rule: 5px solid lightblue; + column-rule-color: blue; + + column-rule-inset-cap-start: 16px; +} +``` + +We then set the {{cssxref("flex-direction")}} on the `.column` container to make its items flow in columns rather than rows. + +```css +.column { + flex-direction: column; +} +``` + +The rest of the CSS is hidden for brevity. + +```css hidden +body { + font-family: sans-serif; + text-align: center; +} +h1 { + font-size: 1.25em; +} +h2 { + font-size: 1em; +} +article { + display: flex; + gap: 5vw; + rule: 1px solid black; + width: 100vw; +} +section { + flex-basis: 45vw; +} +.flexbox > div { + border: 1px solid green; + background-color: lime; + flex: 1 1 auto; + height: 30px; +} +output { + display: inline-block; + width: 2em; +} +p { + margin-top: 2.5em; +} +@layer no-support { + @supports not (column-rule-inset-cap-start: 16px) { + body::before { + content: "Your browser doesn't support the column-rule-inset-cap-start property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} +``` + +```js hidden live-sample___basic +const inset = document.getElementById("inset"); +const containers = document.querySelectorAll(".flexbox"); +const output = document.getElementById("o"); + +inset.addEventListener("input", () => { + const val = `${inset.value}px`; + containers[0].style.columnRuleInsetCapStart = val; + containers[1].style.columnRuleInsetCapStart = val; + output.innerText = val; +}); +``` + +#### Result + +{{EmbedLiveSample("Basic usage", "", "330")}} + +Change the size of the inset. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{cssxref("row-rule-inset-cap-start")}} +- {{cssxref("column-rule-inset-cap-end")}} +- {{cssxref("column-rule-inset-junction-start")}} +- {{cssxref("column-rule-inset-start")}} shorthand +- {{cssxref("column-rule-inset-cap")}} shorthand +- {{cssxref("column-rule-inset")}} shorthand +- {{cssxref("rule-inset-start")}} shorthand +- {{cssxref("rule-inset-cap")}} +- {{cssxref("rule-inset")}} shorthand +- {{cssxref("column-rule-break")}} +- {{cssxref("rule-break")}} shorthand +- {{cssxref("rule-overlap")}} +- {{cssxref("rule-visibility-items")}} +- {{cssxref("rule")}} shorthand +- [CSS gaps](/en-US/docs/Web/CSS/Guides/Gaps) module diff --git a/files/en-us/web/css/reference/properties/column-rule-inset-cap/index.md b/files/en-us/web/css/reference/properties/column-rule-inset-cap/index.md new file mode 100644 index 000000000000000..36a800a66e8cc36 --- /dev/null +++ b/files/en-us/web/css/reference/properties/column-rule-inset-cap/index.md @@ -0,0 +1,505 @@ +--- +title: "`column-rule-inset-cap` CSS property" +short-title: column-rule-inset-cap +slug: Web/CSS/Reference/Properties/column-rule-inset-cap +page-type: css-property +status: + - experimental +browser-compat: css.properties.column-rule-inset-cap +sidebar: cssref +--- + +{{SeeCompatTable}} + +The **`column-rule-inset-cap`** [shorthand](/en-US/docs/Web/CSS/Guides/Cascade/Shorthand_properties) [CSS](/en-US/docs/Web/CSS) property can be used to offset the column rule segment [cap endpoints](#understanding_cap_endpoints) at the container's start and end edges, and endpoints where the segments don't intersect other row or column segments. + +{{InteractiveExample("CSS Demo: rule")}} + +```css interactive-example-choice +column-rule-inset-cap: -20px; +``` + +```css interactive-example-choice +column-rule-inset-cap: 0; +``` + +```css interactive-example-choice +column-rule-inset-cap: 1em; +``` + +```css interactive-example-choice +column-rule-inset-cap: 100%; +``` + +```css interactive-example-choice +column-rule-inset-cap: overlap-join; +``` + +```html interactive-example +
+
+ A + B + C + D + E + F + G + H + I + J + K + L + M + N + O + P + Q + + Y + Z + ! +
+
+``` + +```css interactive-example +#example-element { + display: grid; + grid-template-columns: repeat(7, 1fr); + rule: solid thick rebeccapurple; + column-rule-color: magenta; + gap: 1em; + rule-overlap: column-over-row; + rule-visibility-items: between; + border: 1px solid rebeccapurple; + overflow: visible; + margin: 1em; +} +#example-element i { + padding: 8px; + border: 1px dashed; +} +#y { + grid-column: 4 / 5; + grid-row: 4 / 5; +} +#z { + grid-column: 5 / 6; + grid-row: 4 / 5; +} +#bang { + grid-column: 6 / 7; + grid-row: 4 / 5; +} +``` + +## Constituent properties + +This property is a shorthand for the following CSS properties: + +- {{cssxref("column-rule-inset-cap-end")}} +- {{cssxref("column-rule-inset-cap-start")}} + +## Syntax + +```css +/* Keywords */ +column-rule-inset-cap: overlap-join; + +/* values */ +column-rule-inset-cap: 0; +column-rule-inset-cap: 1em; +column-rule-inset-cap: -5px; +column-rule-inset-cap: -25%; + +/* Two values */ +column-rule-inset-cap: overlap-join 1em; +column-rule-inset-cap: -5px -25%; + +/* Global values */ +column-rule-inset-cap: inherit; +column-rule-inset-cap: initial; +column-rule-inset-cap: revert; +column-rule-inset-cap: revert-layer; +column-rule-inset-cap: unset; +``` + +### Values + +This property is specified as one or two values from the following list: + +- `overlap-join` + - : Resolves to `0`. +- {{cssxref("length-percentage")}} + - : Specifies the size of the inset. [Percentage values](#understanding_percentage_values) are relative to the crossing gap width, which is the width of the `row-gap` for segment endpoints at gap junctions and `0` for endpoints at the container's edge. + +## Description + +The `column-rule-inset-cap` shorthand property can be used to set the {{cssxref("column-rule-inset-cap-end")}} and {{cssxref("column-rule-inset-cap-start")}} properties, insetting or outsetting both the start and end edges of [cap segment endpoints](#understanding_cap_endpoints) in a single declaration. + +If one value is specified, both properties are set to that value. If two values are specified, `-start` is set to the first value and `-end` is set to the second. The default value is `0`, which, in the case of cap endpoints, is the same as `overlap-join`. Positive values reduce (or inset) the segment size, while negative values increase (or outset) it. + +Column rules are painted within a column gap as one or more segments, with segments occurring between: + +- Adjacent columns in CSS grid layouts. +- Flex items or flex lines in flex layouts, depending on the `flex-direction`. +- Columns in multi-col layouts. + +Whether a column rule spans multiple rows or is broken into multiple segments is defined by the {{cssxref("column-rule-break")}} property, with interior breaks between column rule segments being the size of the {{cssxref("row-gap")}}. + +Length `column-rule-inset-cap` values inset segments by the specified value; with negative length values creating an outset, causing end edge cap segments to extend beyond the container's top and bottom edges. Percentage values for end edge cap segments are relative to `0`, so have no effect. + +For interior segments, [percentage values](#understanding_percentage_values) are relative to the size of the {{cssxref("row-gap")}}. Setting `-50%` will extend the segment to the middle of the gap, while `-100%` will extend the segment across the entire gap. + +The `column-rule-inset-cap` property is a constituent property of a few [shorthand properties](/en-US/docs/Web/CSS/Guides/Cascade/Shorthand_properties): + +- To inset the ends of all column segments, the `column-rule-inset-cap` property, along with the {{cssxref("column-rule-inset-junction")}} property, can be set using the {{cssxref("column-rule-inset")}} shorthand. + +- To inset all row and column cap endpoints, the `column-rule-inset-cap` property, along with the {{cssxref("row-rule-inset-cap")}} property, can be set using the {{cssxref("rule-inset-cap")}} shorthand. + +All segment endpoints, including this property's `-junction` and `row-` equivalents, can be set using the {{cssxref("rule-inset")}} shorthand. + +### Understanding cap endpoints + +A _cap segment endpoint_ is any segment endpoint that is not a junction segment endpoint. This includes endpoints at the container's content edges, as well as endpoints at a gap junction where no other row or column segments are present. + +The `column-rule-inset-cap` property can reduce or extend the top, bottom, or both ends of column segments at the top and bottom edge of the container and the segment end at any interior junction where no other segments are present. + +Column cap segments are impacted by the {{cssxref("rule-visibility-items")}} properties, which define whether row- and column-rule segments are painted in gaps adjacent to empty areas. Changing the value from `auto` to `between` or `around` can create additional interior cap segments. + +In the following demonstration, the top of the column segments in the top row and the bottom of the column segments in the bottom row start and end in cap endpoints, respectively. With `column-rule-inset-cap: 16px` set, all the column segment cap endpoints are inset by `16px`. Change the inset `` value to better visualize which segments start or end in cap segment endpoints. + +```html hidden live-sample___caps live-sample___percents +
    +
  • 1
  • +
  • 2
  • +
  • 3
  • +
  • 4
  • +
  • 5
  • +
  • 6
  • +
  • 7
  • +
  • 8
  • +
  • 9
  • +
  • 10
  • +
  • 11
  • +
  • 12
  • +
  • 13
  • +
  • 15
  • +
  • 16
  • +
+ +

+ +

+``` + +```html hidden live-sample___caps +

+ + 16px +

+``` + +```html hidden live-sample___percents +

+ + 100% +

+``` + +```css hidden live-sample___caps live-sample___percents +ul { + display: grid; + grid-template-columns: repeat(6, auto); + list-style-type: none; + gap: 20px; + column-rule: 10px solid olive; + row-rule: 10px solid palegoldenrod; + rule-overlap: column-over-row; + rule-visibility-items: normal; + rule-break: intersection; + column-rule-inset-cap: 16px; + + border: 1px solid; +} +ul { + place-items: center; + width: 95vw; + padding: 0; +} +li { + text-align: center; + font-family: sans-serif; + background-color: #ededed; + padding: 1em; + width: 100%; + box-sizing: border-box; +} +@layer no-support { + @supports not (column-rule-inset-cap: 16px) { + body::before { + content: "Your browser doesn't support the column-rule-inset-cap property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} +``` + +```css hidden live-sample___percents +ul { + column-rule-inset-cap: 100%; + column-rule-style: inset; +} +``` + +```js hidden live-sample___caps live-sample___percents +const inset = document.getElementById("inset"); +const visibility = document.getElementById("visibility"); +const ul = document.getElementById("ul"); +const output = document.getElementById("o"); + +inset.addEventListener("input", () => { + o.innerText = + ul.style.columnRuleInsetCap = `${inset.value}${inset.dataset["unit"]}`; +}); +``` + +```js hidden live-sample___caps +visibility.addEventListener("change", () => { + ul.style.ruleVisibilityItems = `${visibility.value}`; + if (visibility.value == "between") { + ul.style.columnRuleStyle = "repeat(2, solid), double"; + } else if (visibility.value == "around") { + ul.style.columnRuleStyle = "repeat(3, solid), repeat(2, double)"; + } else { + ul.style.columnRuleStyle = "solid"; + } +}); +``` + +```js hidden live-sample___percents +visibility.addEventListener("change", () => { + ul.style.ruleVisibilityItems = `${visibility.value}`; + if (visibility.value == "between") { + ul.style.columnRuleStyle = "repeat(2, inset), double, repeat(2, solid)"; + } else if (visibility.value == "around") { + ul.style.columnRuleStyle = "repeat(3, inset), repeat(2, double)"; + } else { + ul.style.columnRuleStyle = "solid"; + } +}); +``` + +{{EmbedLiveSample("caps", "", "300")}} + +Change the inset. When `0px` is set, the ends of the column rules align with the top and bottom edges of the container. This is the default. Setting `-32px` outsets the segments by `32px`, with the lines being drawn `32px` past the edge of the container. As column rules don't impact the box model, these lines have no impact on the layout of the container or the rest of the content. + +Select `around` as the `rule-visibility-items` value. This value paints rules in a gap segment if at least one of the two adjacent areas is occupied by an item. The start end of the top-most segments are still cap segment endpoints. The bottom-most segments of the double line-style column rules, which appear when the `rule-visibility-items` property is set to `around` do not end in cap endpoints. Rather, the bottom segment of the last two column rules end at _junctions_: interior gaps where row rule segments are present. Therefore, the `column-rule-inset-cap` property does not affect those segment endpoints. + +Select `between` as the `rule-visibility-items` value. This value only paints rules in gap segments if both adjacent areas are occupied by an item. In this example, the bottom row rule ends at the third column gap, with the last row segment being between `9` and `16`. The bottom of the third column rule, shown as a double line, ends at an interior gap. As a row rule segment is present, the column segment does not end in a cap segment endpoint, so it is not affected by the `column-rule-inset-cap` property. The last two column rules, however, end at interior gaps where no other rule segments are present, so these column segments are cap segment endpoints and therefore are affected by the `column-rule-inset-cap` property. + +### Understanding percentage values + +What a percentage value is relative to depends on the endpoint's location. Interior endpoint percentage values are relative to the width of the gap the cap endpoint touches, so generally relative to the {{cssxref("row-gap")}}, plus any additional spacing added due to {{cssxref("align-content")}} values. Percentages at container-edge endpoints are relative to `0`. For example, `column-rule-inset-cap: 50%` resolves to half the gap junction size at an interior cap and `0` at the container edges. + +This example is not broken. When `rule-visibility-items` is set to `normal`, every column cap endpoint abuts the top or bottom edge of the container, so any percentage value set will be relative to `0`. + +{{EmbedLiveSample("percents", "", "300")}} + +Select `around` as the `rule-visibility-items` value. The first three columns end at the container edge, so any percentage value will resolve to `0`. The last two column rules, with the double lines, end at interior gaps where row rule segments are present, so these column segments are not cap segment endpoints. + +Select `between` as the `rule-visibility-items` value. The first two column rules, with the light and dark lines, end at the container edge, so they have a `0` inset. The third column rule, with the double line, ends at an interior gap where a row rule segment is present, so this column segment is not a cap segment endpoint. The last two column rules, with the solid lines, end at interior gaps where no other rule segments are present, so the percentage offset is relative to the size of the {{cssxref("row-gap")}} width, which in this case is `20px`. + +## Formal definition + +{{cssinfo}} + +## Formal syntax + +{{csssyntax}} + +## Examples + +### Basic usage + +This example demonstrates setting `column-rule-inset-cap` to inset the column rule cap segment endpoints on flex containers. + +#### HTML + +```html +

Insetting cap column rule endpoints

+
+
+

flex-direction: row

+
+
+
+
+
+
+
+
+
+
+
+

flex-direction: column

+
+
+
+
+
+
+
+
+
+
+
+``` + +```html hidden +

+ + 16px +

+``` + +#### CSS + +We use the {{cssxref("display")}} property to turn the `.flexbox` elements into flex containers. We balance the items into three flex lines using {{cssxref("flex-wrap")}} and {{cssxref("flex-line-count")}}. We define a `lightblue` {{cssxref("rule")}} to paint both row and column gaps, then overwrite the {{cssxref("column-rule-color")}}, setting darker `blue` column gap decorations. Finally, we set the `column-rule-inset-cap` to `16px`. + +```css +.flexbox { + display: flex; + flex-wrap: balance; + flex-line-count: 3; + gap: 20px; + rule: 5px solid lightblue; + column-rule-color: blue; + + column-rule-inset-cap: 16px; +} +``` + +We also set the {{cssxref("flex-direction")}} on the `.column` container, to change the main axis of the flex container, and make the items flow in columns rather than rows. + +```css +.column { + flex-direction: column; +} +``` + +The rest of the CSS is hidden for brevity. + +```css hidden +body { + font-family: sans-serif; + text-align: center; +} +h1 { + font-size: 1.25em; +} +h2 { + font-size: 1em; +} +article { + display: flex; + gap: 5vw; + rule: 1px solid black; + width: 100vw; +} +section { + flex-basis: 45vw; +} +.flexbox > div { + border: 1px solid green; + background-color: lime; + flex: 1 1 auto; + height: 30px; +} +output { + display: inline-block; + width: 2em; +} +p { + margin-top: 2.5em; +} +@layer no-support { + @supports not (column-rule-inset-cap: 16px) { + body::before { + content: "Your browser doesn't support the column-rule-inset-cap property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} +``` + +```js hidden live-sample___basic +const inset = document.getElementById("inset"); +const containers = document.querySelectorAll(".flexbox"); +const output = document.getElementById("o"); + +inset.addEventListener("input", () => { + const val = `${inset.value}px`; + containers[0].style.columnRuleInsetCap = val; + containers[1].style.columnRuleInsetCap = val; + output.innerText = val; +}); +``` + +#### Result + +{{EmbedLiveSample("Basic usage", "", "330")}} + +Change the size of the inset. Note how the column segments grow and shrink only at their segment cap ends — the ends that don't intersect other column or row segments. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{cssxref("column-rule-inset-cap-end")}} +- {{cssxref("column-rule-inset-cap-start")}} +- {{cssxref("column-rule-inset")}} shorthand +- {{cssxref("row-rule-inset-cap")}} shorthand +- {{cssxref("rule-inset")}} shorthand +- {{cssxref("column-rule-break")}} +- {{cssxref("rule-break")}} shorthand +- {{cssxref("rule-overlap")}} +- {{cssxref("rule-visibility-items")}} +- {{cssxref("rule")}} shorthand +- [CSS gaps](/en-US/docs/Web/CSS/Guides/Gaps) module diff --git a/files/en-us/web/css/reference/properties/row-rule-inset-cap-end/index.md b/files/en-us/web/css/reference/properties/row-rule-inset-cap-end/index.md new file mode 100644 index 000000000000000..4d8136bce56efd0 --- /dev/null +++ b/files/en-us/web/css/reference/properties/row-rule-inset-cap-end/index.md @@ -0,0 +1,515 @@ +--- +title: "`row-rule-inset-cap-end` CSS property" +short-title: row-rule-inset-cap-end +slug: Web/CSS/Reference/Properties/row-rule-inset-cap-end +page-type: css-property +status: + - experimental +browser-compat: css.properties.row-rule-inset-cap-end +sidebar: cssref +--- + +{{SeeCompatTable}} + +The **`row-rule-inset-cap-end`** [CSS](/en-US/docs/Web/CSS) property can be used to offset the end of row rule segment [cap endpoints](#understanding_cap_end). + +{{InteractiveExample("CSS Demo: rule")}} + +```css interactive-example-choice +row-rule-inset-cap-end: -20px; +``` + +```css interactive-example-choice +row-rule-inset-cap-end: 1.25em; +``` + +```css interactive-example-choice +row-rule-inset-cap-end: 0; +``` + +```css interactive-example-choice +row-rule-inset-cap-end: 100%; +``` + +```css interactive-example-choice +row-rule-inset-cap-end: overlap-join; +``` + +```html interactive-example +
+
+ A + B + C + D + E + F + G + H + I + J + K + L + M + N + O + P + Q + R + + U + X + Y + ! +
+
+``` + +```css interactive-example +#example-element { + display: grid; + grid-template-columns: repeat(7, 1fr); + rule: solid thick magenta; + row-rule-color: rebeccapurple; + gap: 1em; + rule-overlap: row-over-column; + rule-visibility-items: between; + border: 1px solid rebeccapurple; + overflow: visible; + margin: 1em; +} +#example-element i { + padding: 8px; + border: 1px dashed; +} +#u { + grid-row: 3 / 4; + grid-column: 7 / 8; +} +#y { + grid-row: 4 / 5; + grid-column: 4 / 5; +} +#x { + grid-column: 3 / 4; + grid-row: 4 / 5; +} +#bang { + grid-column: 6 / 7; + grid-row: 4 / 5; +} +``` + +## Syntax + +```css +/* Keywords */ +row-rule-inset-cap-end: overlap-join; + +/* values */ +row-rule-inset-cap-end: 0; +row-rule-inset-cap-end: 1rem; +row-rule-inset-cap-end: -15px; +row-rule-inset-cap-end: -50%; + +/* Global values */ +row-rule-inset-cap-end: inherit; +row-rule-inset-cap-end: initial; +row-rule-inset-cap-end: revert; +row-rule-inset-cap-end: revert-layer; +row-rule-inset-cap-end: unset; +``` + +### Values + +This property is specified as a single value from the following list: + +- `overlap-join` + - : Resolves to `0`. +- {{cssxref("length-percentage")}} + - : Specifies the size of the inset. Percentage values are relative to the cap endpoint, which is either the height of the `column-gap` width or `0`. + +## Description + +The `row-rule-inset-cap-end` property can be used to inset the end edge of row rule [cap segment endpoints](#understanding_cap_end) at the container's end edge and cap endpoints where no rule segments intersect. The default value is `0`, which is the same as `overlap-join`. Positive values reduce the row rule segment size, while negative values increase it. + +Row rules are painted within a row gap as one or more segments, with segments occurring between: + +- Adjacent rows in CSS grid layouts. +- Adjacent flex items or flex lines in flex layouts, depending on the `flex-direction`. +- Adjacent rows in multi-col layouts if the {{cssxref("column-height")}} is set to a {{cssxref("<length>")}}. + +Whether a row rule spans multiple columns or is broken into multiple segments is defined by the {{cssxref("row-rule-break")}} property, with interior breaks between row rule segments being the size of the {{cssxref("column-gap")}}. + +Length `row-rule-inset-cap-end` values are inset by the value specified for both interior and end edge cap segments. Negative length values create an outset, with end edge cap segments extending beyond the container's end edge. + +[Percentage values](#understanding_percentage_values) for interior cap segment endpoint insets are relative to the size of the {{cssxref("column-gap")}}. For end edge cap segments, percentage values are relative to `0`, so percentage values never inset or outset cap segment endpoints at the container's end edge. + +The `row-rule-inset-cap-end` property is a constituent property of several [shorthand properties](/en-US/docs/Web/CSS/Guides/Cascade/Shorthand_properties): + +- To inset both the start and ends of row rule caps, the `row-rule-inset-cap-end` property, along with the {{cssxref("row-rule-inset-cap-start")}} property, can be set using the {{cssxref("row-rule-inset-cap")}} shorthand. + +- To inset the ends of all row segments, the `row-rule-inset-cap-end` property, along with the {{cssxref("row-rule-inset-junction-end")}} property, can be set using the {{cssxref("row-rule-inset-end")}} shorthand. + +All segment endpoints, including this property's `-start`, `-junction`, and `column-` equivalents, can be set using the {{cssxref("rule-inset")}} shorthand. + +### Understanding cap end + +A _cap segment endpoint_ is any segment endpoint that is not a junction segment endpoint. This includes endpoints at the container's content edges, as well as endpoints at a gap junction where no other column or row segments are present. + +The `row-rule-inset-cap-end` controls the inset of cap segment endpoints occurring at the end of a row rule segment. Depending on the writing mode, the property can inset the right or left edge of row rule segments at interior gaps with no other row or column rule segments, or at the container's end edge. + +This property is affected by the {{cssxref("rule-visibility-items")}} properties, which define whether row- and column-rule segments are painted in gaps adjacent to empty areas. As row cap segment endpoints only exist at the end edge of the container and at interior gaps where no other row or column rule segments are present, whether segments are painted (or would otherwise be painted if the `rule` were set to a visible value) impacts which row segments are end cap segments. + +In the following demonstration, the end segments of row rules with a solid line style end in a cap endpoint. With `row-rule-inset-cap-end: 16px` set, these endpoints are all inset by `16px`. Change the inset `` value to better visualize which segments end in cap segment endpoints. + +```html hidden live-sample___caps live-sample___percents +
    +
  • 1
  • +
  • 2
  • +
  • 3
  • +
  • 4
  • +
  • 5
  • +
  • 6
  • +
  • 7
  • +
  • 8
  • +
  • 9
  • +
  • 10
  • +
  • 11
  • +
  • 12
  • +
  • 13
  • +
  • 14
  • +
  • 15
  • +
  • 16
  • +
  • 18
  • +
  • 22
  • +
  • 24
  • +
+ +

+ +

+``` + +```html hidden live-sample___caps +

+ + -32px +

+``` + +```html hidden live-sample___percents +

+ + 100% +

+``` + +```css hidden live-sample___caps live-sample___percents +ul { + display: grid; + grid-template-columns: repeat(6, auto); + list-style-type: none; + gap: 20px; + row-rule: 10px solid olive; + column-rule: 10px solid palegoldenrod; + rule-overlap: row-over-column; + rule-visibility-items: normal; + rule-break: intersection; + row-rule-inset-cap-end: -32px; + + border: 1px solid; +} +ul { + place-items: center; + width: 95vw; + padding: 0; +} +li { + text-align: center; + font-family: sans-serif; + background-color: #ededed; + padding: 1em; + width: 100%; + box-sizing: border-box; +} +.a { + grid-column: 5 / 6; + grid-row: 3 / 4; +} +.b { + grid-column: 3 / 4; + grid-row: 4 / 5; +} +.c { + grid-column: 5 / 6; + grid-row: 4 / 5; +} +@layer no-support { + @supports not (row-rule-inset-cap-end: 16px) { + body::before { + content: "Your browser doesn't support the row-rule-inset-cap-end property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} +``` + +```css hidden live-sample___percents +ul { + row-rule-inset-cap-end: 100%; + row-rule-style: inset; +} +``` + +```js hidden live-sample___caps live-sample___percents +const inset = document.getElementById("inset"); +const visibility = document.getElementById("visibility"); +const ul = document.getElementById("ul"); +const output = document.getElementById("o"); + +inset.addEventListener("input", () => { + output.innerText = + ul.style.rowRuleInsetCapEnd = `${inset.value}${inset.dataset["unit"]}`; +}); +``` + +```js hidden live-sample___caps +visibility.addEventListener("change", () => { + ul.style.ruleVisibilityItems = `${visibility.value}`; + if (visibility.value == "between") { + ul.style.rowRuleStyle = "repeat(2, solid), double"; + } else if (visibility.value == "around") { + ul.style.rowRuleStyle = "repeat(3, solid), repeat(2, double)"; + } else { + ul.style.rowRuleStyle = "solid"; + } +}); +``` + +```js hidden live-sample___percents +visibility.addEventListener("change", () => { + ul.style.ruleVisibilityItems = `${visibility.value}`; + if (visibility.value == "between") { + ul.style.rowRuleStyle = "repeat(2, inset), double, repeat(2, solid)"; + } else if (visibility.value == "around") { + ul.style.rowRuleStyle = "repeat(3, inset), repeat(2, double)"; + } else { + ul.style.rowRuleStyle = "solid"; + } +}); +``` + +{{EmbedLiveSample("caps", "", "400")}} + +Setting `-32px` outsets the end of all the row rules by `32px`: the lines are drawn `32px` past the right edge of the container. As row rules don't impact the box model, these lines have no impact on the layout of the container or the rest of the content. If `0px` is set, the end of the row rules will align with the edge of the container. This is the default. + +The double line-style row rule segments, which appear when the `rule-visibility-items` property is set to `between`, add a cap endpoint. The `between` value only paints rules in gap segments between two adjacent areas occupied by an item. Because the row rule segment above item `24` ends at an intersection with no other row or column rule segments present, this is a cap endpoint, and therefore is affected by the `row-rule-inset-cap-end` property. The segment above item `22` ends at a gap junction where a rule segment is present, so it is not a cap endpoint. There are fewer segments abutting the right edge of the container, but the remaining segment, between `6` and `12`, remains a cap endpoint. + +Rule segments abutting the end edge of the container are always row-rule cap end segments affected by the value of the `row-rule-inset-cap-end` property. + +### Understanding percentage values + +The length a percentage value is relative to depends on the endpoint location. Interior endpoint percentage values are relative to the width of the gap at the cap endpoint, so relative to the {{cssxref("column-gap")}} if abutting a rule gap, and `0` at the top edge of the container. + +This example isn't broken; all the cap segments end at the container's edge, so all the insets are `0` by default. + +{{EmbedLiveSample("percents", "", "400")}} + +If you select `around` as the `rule-visibility-items` value, the only cap segment endpoints are at the edge of the container, so percentage value insets continue to resolve to `0`. + +Select `between` as the `rule-visibility-items` value. We now have a row rule end cap affected by the inset — see the segment between grid items `18` and `24`! This segment ends at an interior gap where no other rule segments are present, so the percentage inset is relative to the size of the {{cssxref("column-gap")}} width, which in this case is `20px`. Setting `100%` insets the end by `20px`. Setting `-200%` will outset the segment by `40px`, with the lines drawn through the `20px` gap into the next column. + +## Formal definition + +{{cssinfo}} + +## Formal syntax + +{{csssyntax}} + +## Examples + +### Basic usage + +This example demonstrates setting `row-rule-inset-cap-end` to inset the end edge of cap segments on flex containers. + +#### HTML + +```html +

Insetting cap row rule endpoints

+
+
+

flex-direction: row

+
+
+
+
+
+
+
+
+
+
+
+

flex-direction: column

+
+
+
+
+
+
+
+
+
+
+
+``` + +```html hidden +

+ + 16px +

+``` + +#### CSS + +We use the {{cssxref("display")}} property to turn the `.flexbox` elements into flex containers. We balance the items into three flex lines using with {{cssxref("flex-wrap")}} and {{cssxref("flex-line-count")}}. We define a light blue {{cssxref("rule")}} to be painted in both column and row gaps, then overwrite the {{cssxref("row-rule-color")}}, setting darker `blue` vertical gap decorations. Finally, we set the `row-rule-inset-cap-end` to `16px`. + +```css +.flexbox { + display: flex; + flex-wrap: balance; + flex-line-count: 3; + gap: 20px; + rule: 5px solid lightblue; + row-rule-color: blue; + + row-rule-inset-cap-end: 16px; +} +``` + +We also set the {{cssxref("flex-direction")}} on the `.column` container, to change the main axis of the flex container, and make the items flow in columns rather than rows. The rest of the CSS is hidden for brevity. + +```css +.column { + flex-direction: column; +} +``` + +```css hidden +body { + font-family: sans-serif; + text-align: center; +} +h1 { + font-size: 1.25em; +} +h2 { + font-size: 1em; +} +article { + display: flex; + gap: 5vw; + rule: 1px solid black; + width: 100vw; +} +section { + flex-basis: 45vw; +} +.flexbox > div { + border: 1px solid green; + background-color: lime; + flex: 1 1 auto; + height: 30px; +} +output { + display: inline-block; + width: 2em; +} +p { + margin-top: 2.5em; +} +@layer no-support { + @supports not (row-rule-inset-cap-end: 16px) { + body::before { + content: "Your browser doesn't support the row-rule-inset-cap-end property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} +``` + +```js hidden live-sample___basic +const inset = document.getElementById("inset"); +const containers = document.querySelectorAll(".flexbox"); +const output = document.getElementById("o"); + +inset.addEventListener("input", () => { + const val = `${inset.value}px`; + containers[0].style.rowRuleInsetCapEnd = val; + containers[1].style.rowRuleInsetCapEnd = val; + output.innerText = val; +}); +``` + +#### Result + +{{EmbedLiveSample("Basic usage", "", "320")}} + +Change the size of the inset. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{cssxref("row-rule-inset")}} shorthand +- {{cssxref("rule-inset")}} shorthand +- {{cssxref("row-rule-break")}} +- {{cssxref("rule-break")}} shorthand +- {{cssxref("rule-overlap")}} +- {{cssxref("rule-visibility-items")}} +- {{cssxref("rule")}} shorthand +- [CSS gaps](/en-US/docs/Web/CSS/Guides/Gaps) module diff --git a/files/en-us/web/css/reference/properties/row-rule-inset-cap-start/index.md b/files/en-us/web/css/reference/properties/row-rule-inset-cap-start/index.md new file mode 100644 index 000000000000000..b476649e19c5a72 --- /dev/null +++ b/files/en-us/web/css/reference/properties/row-rule-inset-cap-start/index.md @@ -0,0 +1,505 @@ +--- +title: "`row-rule-inset-cap-start` CSS property" +short-title: row-rule-inset-cap-start +slug: Web/CSS/Reference/Properties/row-rule-inset-cap-start +page-type: css-property +status: + - experimental +browser-compat: css.properties.row-rule-inset-cap-start +sidebar: cssref +--- + +{{SeeCompatTable}} + +The **`row-rule-inset-cap-start`** [CSS](/en-US/docs/Web/CSS) property can be used to offset the start of row rule segment [cap endpoints](#understanding_cap_end). + +{{InteractiveExample("CSS Demo: rule")}} + + + +```css interactive-example-choice +row-rule-inset-cap-start: -20px; +``` + +```css interactive-example-choice +row-rule-inset-cap-start: 0; +``` + +```css interactive-example-choice +row-rule-inset-cap-start: 1em; +``` + +```css interactive-example-choice +row-rule-inset-cap-start: 100%; +``` + +```css interactive-example-choice +row-rule-inset-cap-start: overlap-join; +``` + +```html interactive-example +
+
+ A + B + C + D + E + F + G + H + I + J + K + L + M + N + O + P + + R + Z + ! +
+
+``` + +```css interactive-example +#example-element { + display: grid; + grid-template-columns: repeat(7, 1fr); + rule: solid thick magenta; + row-rule-color: rebeccapurple; + gap: 1em; + rule-overlap: row-over-column; + rule-visibility-items: between; + border: 1px solid rebeccapurple; + overflow: visible; + margin: 1em; +} +#example-element i { + padding: 8px; + border: 1px dashed; +} +#r { + grid-column: 5 / 6; + grid-row: 3 / 4; +} +#z { + grid-column: 5 / 6; + grid-row: 4 / 5; +} +#bang { + grid-column: 5 / 6; + grid-row: 5 / 6; +} +``` + +## Syntax + +```css +/* Keywords */ +row-rule-inset-cap-start: overlap-join; + +/* values */ +row-rule-inset-cap-start: 0; +row-rule-inset-cap-start: 1em; +row-rule-inset-cap-start: -5px; +row-rule-inset-cap-start: -25%; + +/* Global values */ +row-rule-inset-cap-start: inherit; +row-rule-inset-cap-start: initial; +row-rule-inset-cap-start: revert; +row-rule-inset-cap-start: revert-layer; +row-rule-inset-cap-start: unset; +``` + +### Values + +This property is specified as a single value from the following list: + +- `overlap-join` + - : Resolves to `0`. +- {{cssxref("length-percentage")}} + - : Specifies the size of the inset. Percentage values are relative to the cap endpoint, which is either the `column-gap` or `0`. + +## Description + +The `row-rule-inset-cap-start` property insets the start of [cap segment endpoints](#understanding_cap_end) at the container's start edge and at cap endpoints where no rule segments intersect. The default value is `0`, which is the same as `overlap-join`. Positive values reduce the segment size, while negative values increase it. + +Row rules are painted within a row gap as one or more segments, with segments occurring between: + +- Adjacent rows in CSS grid layouts. +- Adjacent flex items or flex lines in flex layouts, depending on the `flex-direction`. +- Adjacent rows in multi-col layouts, which may exist when {{cssxref("column-height")}} is set to a {{cssxref("<length>")}}. + +Length `row-rule-inset-cap-start` values inset the start of both interior and start-edge cap segment endpoints by the specified value. Negative length values create an outset, with container-edge cap segments extending beyond the container's start edge. + +[Percentage value](#understanding_percentage_values) insets for interior cap segments are relative to the size of the {{cssxref("column-gap")}}. For cap segments at the container start edge, percentage values are relative to `0`, so they are always `0px`. + +The `row-rule-inset-cap-start` property is a constituent property of several [shorthand properties](/en-US/docs/Web/CSS/Guides/Cascade/Shorthand_properties): + +- To inset both the left and right ends of row cap segments, the `row-rule-inset-cap-start` property, along with the {{cssxref("row-rule-inset-cap-end")}} property, can be set using the {{cssxref("row-rule-inset-cap")}} shorthand. + +- To inset the start edge of all row segments, the `row-rule-inset-cap-start` property, along with the {{cssxref("row-rule-inset-junction-start")}} property, can be set using the {{cssxref("row-rule-inset-start")}} shorthand. + +All segment endpoints, including this property's `-end`, `-junction`, and `column-` equivalents, can be set using the {{cssxref("rule-inset")}} shorthand. + +### Understanding cap start + +A _cap segment endpoint_ is any segment endpoint that is not a junction segment endpoint. This includes endpoints at the container's content edges, as well as endpoints at a gap junction where no other rule segments are present. + +The `row-rule-inset-cap-start` controls the start inset of row rules with cap endpoints. The property can shrink or extend the start of: + +- Row rule segments abutting the container start edge. +- Row rule segments whose left side abuts an interior gap where no other row or column rule segments are present. + +Row cap segments are impacted by the {{cssxref("rule-visibility-items")}} properties, which define whether row- and column-rule segments are painted in gaps adjacent to empty areas. Changing the value from `auto` to `between` or `around` can create additional interior cap segments. + +In the following demonstration, the leftmost segments of the row rules abutting the container edge start in a cap endpoint. With `row-rule-inset-cap-start: -32px` set, these endpoints are all outset by `32px`. As row rules don't impact the box model, these protruding lines don't affect the content's layout. Change the inset `` value to better visualize which segments start with cap segment endpoints. + +```html hidden live-sample___caps live-sample___percents +
    +
  • 1
  • +
  • 2
  • +
  • 3
  • +
  • 4
  • +
  • 5
  • +
  • 6
  • +
  • 7
  • +
  • 8
  • +
  • 9
  • +
  • 10
  • +
  • 11
  • +
  • 12
  • +
  • 13
  • +
  • 14
  • +
  • 15
  • +
  • 16
  • +
  • 17
  • +
+ +

+ +

+``` + +```html hidden live-sample___caps +

+ + -32px +

+``` + +```html hidden live-sample___percents +

+ + 100% +

+``` + +```css hidden live-sample___caps live-sample___percents +ul { + display: grid; + margin: 0 20px; + grid-template-columns: repeat(6, auto); + list-style-type: none; + gap: 20px; + row-rule: 10px solid olive; + column-rule: 10px solid palegoldenrod; + rule-overlap: column-over-row; + rule-visibility-items: normal; + rule-break: intersection; + row-rule-inset-cap-start: -32px; + + border: 1px solid; + margin: auto 40px; +} +ul { + place-items: center; + padding: 0; +} +li { + text-align: center; + font-family: sans-serif; + background-color: #ededed; + padding: 1em; + width: 100%; + box-sizing: border-box; +} +li:nth-of-type(n + 9) { + grid-row: 3 / 4; +} +li:nth-of-type(n + 13) { + grid-row: 4 / 5; +} +li:nth-of-type(12), +li:nth-of-type(16) { + grid-column: 5/6; +} +li:nth-of-type(17) { + grid-column: 6/7; +} + +@layer no-support { + @supports not (row-rule-inset-cap-start: 16px) { + body::before { + content: "Your browser doesn't support the row-rule-inset-cap-start property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} +``` + +```css hidden live-sample___percents +ul { + row-rule-inset-cap-start: 100%; +} +``` + +```js hidden live-sample___caps live-sample___percents +const inset = document.getElementById("inset"); +const visibility = document.getElementById("visibility"); +const ul = document.getElementById("ul"); +const output = document.getElementById("o"); + +inset.addEventListener("input", () => { + output.innerText = + ul.style.rowRuleInsetCapStart = `${inset.value}${inset.dataset["unit"]}`; +}); +``` + +```js hidden live-sample___caps live-sample___percents +visibility.addEventListener("change", () => { + ul.style.ruleVisibilityItems = `${visibility.value}`; + if (visibility.value == "between") { + ul.style.rowRuleStyle = "repeat(2, solid), double"; + } else { + ul.style.rowRuleStyle = "solid"; + } +}); +``` + +{{EmbedLiveSample("caps", "", "350")}} + +Change the inset. Setting `0px` aligns the start of the row rules with the start of the container. This is the default. + +Select `between` as the `rule-visibility-items` value. This value paints rules in a gap segment only if the two adjacent areas are occupied by items. Again, we have row rule cap endpoints at the start edge of the container. The third row rule, denoted with a double line style, has an additional cap endpoint segment: the left side of the segment between items `12` and `16`. This does not meet any other rule segments and is therefore affected by the `row-rule-inset-cap-start` property. + +In this case, the `around` value of the `rule-visibility-items` property, which paints rules in a gap segment as long as one adjacent area is occupied by an item, did not create additional cap segment endpoints. The rule start of the segment between `12` and `16` intersects with the column rule segments in the column-gap to the left of those items, creating junction, not cap, segment endpoints. Junction endpoints are inset using the {{cssxref("row-rule-inset-junction-start")}} property instead. + +### Understanding percentage values + +The length a percentage value is relative to depends on the endpoint location. Interior endpoint percentage values are relative to the width of the gap at the cap endpoint, so relative to the {{cssxref("column-gap")}} if abutting a rule gap, and `0` at the edge of the container. + +This example isn't broken; all the cap segments start at the container's edge, so all the insets are `0` by default. + +{{EmbedLiveSample("percents", "", "350")}} + +The slider only has an effect when the `rule-visibility-items` value is set to `between`, and then only on the single inner cap endpoint segment that this value creates — the segment between `12` and `16`. For this segment only, the percentage offset is relative to the size of the {{cssxref("column-gap")}} width, which in this case is `20px`. Setting `100%` insets the start of the cap segment by `20px`. Setting `-200%` outsets the segment by `40px`, with the rule segment drawn through the `20px` gap and into the previous column. + +## Formal definition + +{{cssinfo}} + +## Formal syntax + +{{csssyntax}} + +## Examples + +### Basic usage + +This example demonstrates setting `row-rule-inset-cap-start` to inset the start edge of cap segments on flex containers. + +#### HTML + +```html +

Insetting cap row rule endpoints

+
+
+

flex-direction: row

+
+
+
+
+
+
+
+
+
+
+
+

flex-direction: column

+
+
+
+
+
+
+
+
+
+
+
+``` + +```html hidden +

+ + 16px +

+``` + +#### CSS + +We use the {{cssxref("display")}} property to turn the `.flexbox` elements into flex containers. We balance the items into three flex lines using with {{cssxref("flex-wrap")}} and {{cssxref("flex-line-count")}}. We define a light blue {{cssxref("rule")}} to be painted in both column and row gaps, then overwrite the {{cssxref("row-rule-color")}}, setting darker `blue` row gap decorations. Finally, we set the `row-rule-inset-cap-start` to `16px`. + +```css +.flexbox { + display: flex; + flex-wrap: balance; + flex-line-count: 3; + gap: 20px; + rule: 5px solid lightblue; + row-rule-color: blue; + + row-rule-inset-cap-start: 16px; +} +``` + +We also set the {{cssxref("flex-direction")}} on the `.column` container, to change the main axis of the flex container, and make the items flow in columns rather than rows. + +```css +.column { + flex-direction: column; +} +``` + +The rest of the CSS is hidden for brevity. + +```css hidden +body { + font-family: sans-serif; + text-align: center; +} +h1 { + font-size: 1.25em; +} +h2 { + font-size: 1em; +} +article { + display: flex; + gap: 42px; + rule: 1px solid black; + width: 100vw; + padding: 0 50px; + box-sizing: border-box; +} +section { + flex-basis: 45vw; +} +.flexbox > div { + border: 1px solid green; + background-color: lime; + flex: 1 1 auto; + height: 30px; +} +output { + display: inline-block; + width: 2em; +} +p { + margin-top: 2.5em; +} +@layer no-support { + @supports not (row-rule-inset-cap-start: 16px) { + body::before { + content: "Your browser doesn't support the row-rule-inset-cap-start property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} +``` + +```js hidden live-sample___basic +const inset = document.getElementById("inset"); +const containers = document.querySelectorAll(".flexbox"); +const output = document.getElementById("o"); + +inset.addEventListener("input", () => { + const val = `${inset.value}px`; + containers[0].style.rowRuleInsetCapStart = val; + containers[1].style.rowRuleInsetCapStart = val; + output.innerText = val; +}); +``` + +#### Result + +{{EmbedLiveSample("Basic usage", "", "320")}} + +Change the size of the inset. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{cssxref("column-rule-inset-cap-start")}} +- {{cssxref("row-rule-inset-cap-end")}} +- {{cssxref("row-rule-inset-junction-start")}} +- {{cssxref("row-rule-inset-start")}} shorthand +- {{cssxref("row-rule-inset-cap")}} shorthand +- {{cssxref("row-rule-inset")}} shorthand +- {{cssxref("rule-inset-start")}} shorthand +- {{cssxref("rule-inset-cap")}} +- {{cssxref("rule-inset")}} shorthand +- {{cssxref("row-rule-break")}} +- {{cssxref("rule-break")}} shorthand +- {{cssxref("rule-overlap")}} +- {{cssxref("rule-visibility-items")}} +- {{cssxref("rule")}} shorthand +- [CSS gaps](/en-US/docs/Web/CSS/Guides/Gaps) module diff --git a/files/en-us/web/css/reference/properties/row-rule-inset-cap/index.md b/files/en-us/web/css/reference/properties/row-rule-inset-cap/index.md new file mode 100644 index 000000000000000..aee57473814419a --- /dev/null +++ b/files/en-us/web/css/reference/properties/row-rule-inset-cap/index.md @@ -0,0 +1,525 @@ +--- +title: "`row-rule-inset-cap` CSS property" +short-title: row-rule-inset-cap +slug: Web/CSS/Reference/Properties/row-rule-inset-cap +page-type: css-property +status: + - experimental +browser-compat: css.properties.row-rule-inset-cap +sidebar: cssref +--- + +{{SeeCompatTable}} + +The **`row-rule-inset-cap`** [shorthand](/en-US/docs/Web/CSS/Guides/Cascade/Shorthand_properties) [CSS](/en-US/docs/Web/CSS) property can be used to offset the row rule segment [cap endpoints](#understanding_cap_endpoints) at the container's left and right edges, and endpoints where the segments don't intersect other column or row segments. + +{{InteractiveExample("CSS Demo: rule")}} + +```css interactive-example-choice +row-rule-inset-cap: -20px; +``` + +```css interactive-example-choice +row-rule-inset-cap: 0; +``` + +```css interactive-example-choice +row-rule-inset-cap: 1em; +``` + +```css interactive-example-choice +row-rule-inset-cap: 100%; +``` + +```css interactive-example-choice +row-rule-inset-cap: overlap-join; +``` + +```html interactive-example +
+
+ A + B + C + D + E + F + G + H + I + J + K + L + M + N + O + P + + R + Z + ! +
+
+``` + +```css interactive-example +#example-element { + display: grid; + grid-template-columns: repeat(7, 1fr); + rule: solid thick rebeccapurple; + row-rule-color: magenta; + gap: 0.5em; + rule-overlap: row-over-column; + rule-visibility-items: between; + border: 1px solid rebeccapurple; + overflow: visible; + margin: 1em; +} +#example-element i { + padding: 8px; + border: 1px dashed; +} +#r { + grid-column: 5 / 6; + grid-row: 3 / 4; +} +#z { + grid-column: 5 / 6; + grid-row: 4 / 5; +} +#bang { + grid-column: 5 / 6; + grid-row: 5 / 6; +} +``` + +## Constituent properties + +This property is a shorthand for the following CSS properties: + +- {{cssxref("row-rule-inset-cap-end")}} +- {{cssxref("row-rule-inset-cap-start")}} + +## Syntax + +```css +/* Keywords */ +row-rule-inset-cap: overlap-join; + +/* values */ +row-rule-inset-cap: 0; +row-rule-inset-cap: 1em; +row-rule-inset-cap: -5px; +row-rule-inset-cap: -25%; + +/* Two values */ +row-rule-inset-cap: overlap-join 1em; +row-rule-inset-cap: -5px -25%; + +/* Global values */ +row-rule-inset-cap: inherit; +row-rule-inset-cap: initial; +row-rule-inset-cap: revert; +row-rule-inset-cap: revert-layer; +row-rule-inset-cap: unset; +``` + +### Values + +This property is specified as a one or two values from the following list: + +- `overlap-join` + - : Resolves to `0`. +- {{cssxref("length-percentage")}} + - : Specifies the size of the inset. [Percentage values](#understanding_percentage_values) are relative to the crossing gap width, which is the width of the `column-gap` for segment endpoints at gap junctions and `0` for endpoints at the container's edge. + +## Description + +The `row-rule-inset-cap` shorthand property can be used to set the {{cssxref("row-rule-inset-cap-start")}} and {{cssxref("row-rule-inset-cap-end")}} properties, insetting or outsetting both the left and right edges of [cap segment endpoints](#understanding_cap_endpoints) in a single declaration. + +If one value is specified, both properties are set to that value. If two values are specified, `-start` is set to the first value and `-end` is set to the second. The default value is `0`, which in the case of cap endpoints, is the same as `overlap-join`. Positive values reduce, or inset, the segment size, while negative values increase, or outset, it. + +Row rules are painted within a row gap as one or more segments, with segments occurring between: + +- Adjacent rows in CSS grid layouts. +- Adjacent flex items or flex lines in flex layouts, depending on the `flex-direction`. +- Adjacent rows in multi-col layouts, which may exist when {{cssxref("column-height")}} is set to a {{cssxref("<length>")}}. + +Whether a row rule spans multiple columns or is broken into multiple segments is defined by the {{cssxref("row-rule-break")}} property, with interior breaks between row rule segments generally being the size of the {{cssxref("column-gap")}}. + +Length `row-rule-inset-cap` values inset segments by the specified value. Negative length values create an outset, making the segment wider and causing cap segments on the left and right edges of the container to extend beyond the container's edge. + +[Percentage values](#understanding_percentage_values) are relative to the size of the {{cssxref("column-gap")}} for interior segments. Setting `-50%` will extend the segment to the middle of the gap, while `-100%` will extend the segment across the entire gap. For cap segments at the container's edge, percentage values are relative to `0`, so percentage values have no effect on cap segment endpoints at the container's edge. + +The `row-rule-inset-cap` property is a constituent property of a few [shorthand properties](/en-US/docs/Web/CSS/Guides/Cascade/Shorthand_properties): + +- To inset the left and right sides of all row segments, the `row-rule-inset-cap` property, along with the {{cssxref("row-rule-inset-junction")}} property, can be set using the {{cssxref("row-rule-inset")}} shorthand. + +- To inset both row and column cap segment endpoints, the `row-rule-inset-cap` property, along with the {{cssxref("column-rule-inset-cap")}} property, can be set using the {{cssxref("rule-inset-cap")}} shorthand. + +All segment endpoints, including this property's `-junction` and `column-` equivalents, can be set using the {{cssxref("rule-inset")}} shorthand. + +### Understanding cap endpoints + +A _cap segment endpoint_ is any segment endpoint that is not a junction segment endpoint. This includes endpoints at the container's content edges, as well as endpoints at a gap junction where no other column or row segments are present. + +The `row-rule-inset-cap` property can outset or inset the start and end of row rules at the container edge, and the start and end of interior row segments where no other segments are present. + +Cap segments are impacted by the {{cssxref("rule-visibility-items")}} properties, which define whether row- and column-rule segments are painted in gaps adjacent to empty areas. Changing the value from `auto` to `between` or `around` can create additional interior cap segments. + +In the following demonstration, the rows end in cap endpoints at the container's left and right edges. With `row-rule-inset-cap: -32px` set, these endpoints are outset by `32px`. Change the inset `` value to better visualize which segments start or end with cap segment endpoints. + +```html hidden live-sample___caps live-sample___percents +
    +
  • 1
  • +
  • 2
  • +
  • 3
  • +
  • 4
  • +
  • 5
  • +
  • 6
  • +
  • 7
  • +
  • 8
  • +
  • 9
  • +
  • 10
  • +
  • 11
  • +
  • 12
  • +
  • 13
  • +
  • 14
  • +
  • 15
  • +
  • 16
  • +
  • 17
  • +
+ +

+ +

+``` + +```html hidden live-sample___caps +

+ + -32px +

+``` + +```html hidden live-sample___percents +

+ + 100% +

+``` + +```css hidden live-sample___caps live-sample___percents +ul { + display: grid; + margin: 0 20px; + grid-template-columns: repeat(6, auto); + list-style-type: none; + gap: 20px; + row-rule: 10px solid olive; + column-rule: 10px solid palegoldenrod; + rule-overlap: column-over-row; + rule-visibility-items: normal; + rule-break: intersection; + row-rule-inset-cap: -32px; + + border: 1px solid; + margin: auto 40px; +} +ul { + place-items: center; + padding: 0; +} +li { + text-align: center; + font-family: sans-serif; + background-color: #ededed; + padding: 1em; + width: 100%; + box-sizing: border-box; +} +li:nth-of-type(n + 9) { + grid-row: 3 / 4; +} +li:nth-of-type(n + 13) { + grid-row: 4 / 5; +} +li:nth-of-type(12), +li:nth-of-type(16) { + grid-column: 5/6; +} +li:nth-of-type(17) { + grid-column: 6/7; +} +@layer no-support { + @supports not (row-rule-inset-cap: 16px) { + body::before { + content: "Your browser doesn't support the row-rule-inset-cap property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} +``` + +```css hidden live-sample___percents +ul { + row-rule-inset-cap: 100%; +} +``` + +```js hidden live-sample___caps live-sample___percents +const inset = document.getElementById("inset"); +const visibility = document.getElementById("visibility"); +const ul = document.getElementById("ul"); +const output = document.getElementById("o"); + +inset.addEventListener("input", () => { + o.innerText = + ul.style.rowRuleInsetCap = `${inset.value}${inset.dataset["unit"]}`; +}); +``` + +```js hidden live-sample___caps +visibility.addEventListener("change", () => { + ul.style.ruleVisibilityItems = `${visibility.value}`; + if (visibility.value == "between") { + ul.style.rowRuleStyle = "repeat(2, solid), double"; + } else if (visibility.value == "around") { + ul.style.rowRuleStyle = "repeat(3, solid), repeat(2, double)"; + } else { + ul.style.rowRuleStyle = "solid"; + } +}); +``` + +```js hidden live-sample___percents +visibility.addEventListener("change", () => { + ul.style.ruleVisibilityItems = `${visibility.value}`; + if (visibility.value == "between") { + ul.style.rowRuleStyle = "repeat(2, inset), double, repeat(2, solid)"; + } else if (visibility.value == "around") { + ul.style.rowRuleStyle = "repeat(3, inset), repeat(2, double)"; + } else { + ul.style.rowRuleStyle = "solid"; + } +}); +``` + +{{EmbedLiveSample("caps", "", "380")}} + +Setting `0px` aligns the row rule ends with the left and right container edges. This is the default. + +Select `between` as the `rule-visibility-items` value. This value paints rules in gap segments only if the two adjacent areas are occupied by items. Again, we have row rule cap endpoints at the start edge of the container, but now we have none at the end edge. The third row rule, denoted with a double-line style, has two additional cap endpoints: the end-side of the segment between `11` and `15` and the start-side of the segment between `12` and `16`. These do not meet any other rule segments; therefore, they are affected by the `row-rule-inset-cap-start` property. + +In this case, the `around` value of the `rule-visibility-items` property, which paints rules in a gap segment as long as one adjacent area is occupied by an item, did not create additional cap segment endpoints. All the interior segment endpoints end in junctions where there are column segments, thus creating junction, not cap, segment endpoints. Junction endpoints can be inset using the {{cssxref("row-rule-inset-junction")}} shorthand property. + +### Understanding percentage values + +The length a percentage value is relative to depends on the endpoint location. Interior endpoint percentage values are relative to the width of the gap at the cap endpoint, so relative to the {{cssxref("column-gap")}} if abutting a rule gap, plus any additional spacing added due to {{cssxref("justify-content")}} settings, and `0` at the edge of the container. For example, `row-rule-inset-cap: 50%` resolves to half the gap junction size at an interior cap (half the size of the `column-gap` value), and `0` at the container edges. + +This example is not broken. When `rule-visibility-items` is set to `normal`, every row cap endpoint abuts the left or right edge of the container, so any percentage value set will be relative to `0`. + +{{EmbedLiveSample("percents", "", "380")}} + +Select `around` as the `rule-visibility-items` value. The first three rows start and the first and last row end at the container edge. Any percentage values for these row cap segment endpoints will resolve to `0`. All the other segments end at interior gaps where column rule segments are present, so these row segments are not cap segment endpoints. + +Select `between` as the `rule-visibility-items` value. As in the previous demonstration, this value creates two interior cap segment endpoints: the right side of the segment between items `11` and `15` and the left side of segment between items `12` and `16` again do not meet any other rule segments. For these two cap endpoints, the percentage offset is relative to the size of the {{cssxref("column-gap")}} width, which in this case is `20px`. + +## Formal definition + +{{cssinfo}} + +## Formal syntax + +{{csssyntax}} + +## Examples + +### Basic usage + +This example demonstrates setting `row-rule-inset-cap` to inset the row rule cap segment endpoints on flex containers. + +#### HTML + +```html +

Insetting cap row rule endpoints

+
+
+

flex-direction: row

+
+
+
+
+
+
+
+
+
+
+
+

flex-direction: column

+
+
+
+
+
+
+
+
+
+
+
+``` + +```html hidden +

+ + 16px +

+``` + +#### CSS + +We use the {{cssxref("display")}} property to turn the `.flexbox` elements into flex containers. We balance the items into three flex lines using {{cssxref("flex-wrap")}} and {{cssxref("flex-line-count")}}. We define a `lightblue` {{cssxref("rule")}} to paint both column and row gaps, then overwrite the {{cssxref("row-rule-color")}}, setting darker `blue` row gap decorations. Finally, we set the `row-rule-inset-cap` to `16px`. + +```css +.flexbox { + display: flex; + flex-wrap: balance; + flex-line-count: 3; + gap: 20px; + rule: 5px solid lightblue; + row-rule-color: blue; + + row-rule-inset-cap: 16px; +} +``` + +We also set the {{cssxref("flex-direction")}} on the `.column` container, to change the main axis of the flex container, and make the items flow in columns rather than rows. + +```css +.column { + flex-direction: column; +} +``` + +The rest of the CSS is hidden for brevity. + +```css hidden +body { + font-family: sans-serif; + text-align: center; +} +h1 { + font-size: 1.25em; +} +h2 { + font-size: 1em; +} +article { + display: flex; + gap: 5vw; + rule: 1px solid black; + width: 100vw; +} +section { + flex-basis: 45vw; +} +.flexbox > div { + border: 1px solid green; + background-color: lime; + flex: 1 1 auto; + height: 30px; +} +output { + display: inline-block; + width: 2em; +} +p { + margin-top: 2.5em; +} +@layer no-support { + @supports not (row-rule-inset-cap: 16px) { + body::before { + content: "Your browser doesn't support the row-rule-inset-cap property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} +``` + +```js hidden live-sample___basic +const inset = document.getElementById("inset"); +const containers = document.querySelectorAll(".flexbox"); +const output = document.getElementById("o"); + +inset.addEventListener("input", () => { + const val = `${inset.value}px`; + containers[0].style.rowRuleInsetCap = val; + containers[1].style.rowRuleInsetCap = val; + output.innerText = val; +}); +``` + +#### Result + +{{EmbedLiveSample("Basic usage", "", "330")}} + +Change the size of the inset. Note how the row segments grow and shrink only at segment cap ends, either their left side, their right side, or both directions — the ends that don't intersect other row or column segments. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{cssxref("row-rule-inset-cap-end")}} +- {{cssxref("row-rule-inset-cap-start")}} +- {{cssxref("row-rule-inset")}} shorthand +- {{cssxref("column-rule-inset-cap")}} shorthand +- {{cssxref("rule-inset")}} shorthand +- {{cssxref("row-rule-break")}} +- {{cssxref("rule-break")}} shorthand +- {{cssxref("rule-overlap")}} +- {{cssxref("rule-visibility-items")}} +- {{cssxref("rule")}} shorthand +- [CSS gaps](/en-US/docs/Web/CSS/Guides/Gaps) module diff --git a/files/en-us/web/css/reference/properties/rule-inset-cap/index.md b/files/en-us/web/css/reference/properties/rule-inset-cap/index.md new file mode 100644 index 000000000000000..334f2153ee35321 --- /dev/null +++ b/files/en-us/web/css/reference/properties/rule-inset-cap/index.md @@ -0,0 +1,454 @@ +--- +title: "`rule-inset-cap` CSS property" +short-title: rule-inset-cap +slug: Web/CSS/Reference/Properties/rule-inset-cap +page-type: css-property +status: + - experimental +browser-compat: css.properties.rule-inset-cap +sidebar: cssref +--- + +{{SeeCompatTable}} + +The **`rule-inset-cap`** [CSS](/en-US/docs/Web/CSS) [shorthand](/en-US/docs/Web/CSS/Guides/Cascade/Shorthand_properties) property can be used to offset the start and end of column and row rule segment [cap endpoints](#understanding_cap_end). + +{{InteractiveExample("CSS Demo: rule")}} + + + +```css interactive-example-choice +rule-inset-cap: -20px; +``` + +```css interactive-example-choice +rule-inset-cap: 0; +``` + +```css interactive-example-choice +rule-inset-cap: 1em; +``` + +```css interactive-example-choice +rule-inset-cap: 100%; +``` + +```css interactive-example-choice +rule-inset-cap: overlap-join; +``` + +```html interactive-example +
+
+ A + B + C + D + E + F + G + H + I + J + K + L + M + N + O + P + Q + + Y + Z + ! +
+
+``` + +```css interactive-example +#example-element { + display: grid; + grid-template-columns: repeat(7, 1fr); + rule: solid thick magenta; + column-rule-color: rebeccapurple; + gap: 1em; + rule-overlap: column-over-row; + rule-visibility-items: between; + border: 1px solid rebeccapurple; + overflow: visible; + margin: 1em; +} +#example-element i { + padding: 8px; + border: 1px dashed; +} +#y { + grid-column: 4 / 5; + grid-row: 4 / 5; +} +#z { + grid-column: 5 / 6; + grid-row: 4 / 5; +} +#bang { + grid-column: 6 / 7; + grid-row: 4 / 5; +} +``` + +## Constituent properties + +This property is a shorthand for the following CSS properties: + +- {{cssxref("column-rule-inset-cap")}} +- {{cssxref("row-rule-inset-cap")}} + +## Syntax + +```css +/* Keywords */ +rule-inset-cap: overlap-join; + +/* A value */ +rule-inset-cap: 0; +rule-inset-cap: 1em; +rule-inset-cap: -5px; +rule-inset-cap: -25%; + +/* Global values */ +rule-inset-cap: inherit; +rule-inset-cap: initial; +rule-inset-cap: revert; +rule-inset-cap: revert-layer; +rule-inset-cap: unset; +``` + +### Values + +This property is specified from the following list: + +- `overlap-join` + - : Resolves to `0`. +- {{cssxref("length-percentage")}} + - : Specifies the size of the inset. Percentage values resolve to `0` for caps at the container's edge. For interior gaps, percentages are relative to the height of the adjacent `row-gap` for column segment caps, or the width of the adjacent `column-gap` for row segment caps. + +## Description + +The `rule-inset-cap` shorthand property sets the {{cssxref("column-rule-inset-cap")}} and {{cssxref("row-rule-inset-cap")}} properties, insetting cap segment endpoints by the specified values. Positive values reduce the segment size, while negative values increase it. + +The `rule-inset-cap` property, along with the {{cssxref("rule-inset-junction")}} property, can be set using the {{cssxref("rule-inset")}} shorthand. + +## Formal definition + +{{cssinfo}} + +## Formal syntax + +{{csssyntax}} + +## Examples + +### Basic usage + +This example shows how to set `rule-inset-cap` to inset the endpoints of cap segments on flex containers. + +#### HTML + +```html +

Insetting cap endpoints

+
+
+

flex-direction: row

+
+
+
+
+
+
+
+
+
+
+
+

flex-direction: column

+
+
+
+
+
+
+
+
+
+
+
+``` + +```html hidden +

+ + 16px +

+``` + +#### CSS + +We use the {{cssxref("display")}} property to turn the `.flexbox` elements into flex containers. We balance the items into three flex lines using {{cssxref("flex-wrap")}} and {{cssxref("flex-line-count")}}. We define a light blue {{cssxref("rule")}} to paint in both row and column gaps, then override the {{cssxref("column-rule-color")}}, setting darker `blue` vertical gap decorations. Finally, we set the `rule-inset-cap` to `16px`. + +```css +.flexbox { + display: flex; + flex-wrap: balance; + flex-line-count: 3; + gap: 20px; + rule: 5px solid lightblue; + column-rule-color: blue; + + rule-inset-cap: 16px; +} +``` + +We also set the {{cssxref("flex-direction")}} on the `.column` container to make its items flow in columns rather than rows. We've hidden the other CSS styles, and the code that make the form interactive, for brevity. + +```css +.column { + flex-direction: column; +} +``` + +```css hidden +body { + font-family: sans-serif; + text-align: center; +} +h1 { + font-size: 1.25em; +} +h2 { + font-size: 1em; +} +article { + display: flex; + gap: 5vw; + rule: 1px solid black; + width: 90vw; + margin: auto; +} +section { + flex-basis: 45vw; +} +.flexbox > div { + border: 1px solid green; + background-color: lime; + flex: 1 1 auto; + height: 30px; +} +output { + display: inline-block; + width: 2em; +} +p { + margin-top: 2.5em; +} +@layer no-support { + @supports not (rule-inset-cap: 16px) { + body::before { + content: "Your browser doesn't support the rule-inset-cap property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} +``` + +```js hidden +const inset = document.getElementById("inset"); +const containers = document.querySelectorAll(".flexbox"); +const output = document.getElementById("o"); + +inset.addEventListener("input", () => { + const val = `${inset.value}px`; + containers[0].style.ruleInsetCap = val; + containers[1].style.ruleInsetCap = val; + output.innerText = val; +}); +``` + +#### Result + +{{EmbedLiveSample("Basic usage", "", "300")}} + +Change the size of the inset. + +### Inner cap segments + +This example shows how to set `rule-inset-cap` to inset the endpoints of cap segments on a grid container, and how the {{cssxref("rule-visibility-items")}} property can turn inner endpoints into cap segment endpoints. + +#### HTML + +We include an unordered list ({{htmlelement("ul")}}) as our container for several list items ({{htmlelement("li")}}). + +We also include a {{htmlelement("select")}} element with an {{htmlelement("option")}} for each `rule-visibility-items` keyword, and an {{htmlelement("input")}} of type {{HTMLElement("input/range", "range")}}. + +```html live-sample___caps +
    +
  • 1
  • +
  • 2
  • +
  • 3
  • +
  • 4
  • +
  • 5
  • +
  • 6
  • +
  • 7
  • +
  • 8
  • +
  • 9
  • +
  • 10
  • +
  • 11
  • +
  • 12
  • +
  • 13
  • +
  • 14
  • +
  • 15
  • +
  • 16
  • +
  • 17
  • +
+ +

+ +

+ +

+ + +

+``` + +#### CSS + +We create a grid container by setting the {{cssxref("display")}} to grid, creating 6 columns with {{cssxref("grid-template-columns")}}, and adding a `20px` {{cssxref("gap")}}. We use the {{cssxref("rule")}} property to define our rules, overriding the row rule color with the {{cssxref("row-rule-color")}} property. We set the {{cssxref("rule-break")}} property to break the rules at each intersection, making each rule segment distinct. We explicitly set {{cssxref("rule-visibility-items")}} to the default value of `normal`. We then use the `rule-inset-cap` property to inset all the cap segment endpoints by `16px`. + +```css +ul { + display: grid; + grid-template-columns: repeat(6, auto); + gap: 20px; + rule: 10px solid olive; + row-rule-color: palegoldenrod; + rule-break: intersection; + rule-visibility-items: normal; + + rule-inset-cap: 16px; +} +``` + +We've hidden the other CSS styles, and the code that make the form interactive, for brevity. + +```css hidden +ul { + place-items: center; + padding: 0; + list-style-type: none; + border: 1px solid; + margin: 40px; +} +li { + text-align: center; + font-family: sans-serif; + background-color: #ededed; + padding: 1em; + width: 100%; + box-sizing: border-box; +} +li:nth-of-type(n + 9) { + grid-row: 3 / 4; +} +li:nth-of-type(n + 12) { + grid-row: 4 / 5; +} +li:nth-of-type(10) { + grid-column: 5/6; +} +li:nth-of-type(11) { + grid-column: 6/7; +} + +li:nth-of-type(15) { + grid-area: 4 / 5 / 5 / 6; +} +li:nth-of-type(16) { + grid-area: 4 / 6 / 5 / 7; +} +li:nth-of-type(17) { + display: none; + grid-area: 5 / 6 / 6 / 7; +} +@layer no-support { + @supports not (rule-inset-cap: 16px) { + body::before { + content: "Your browser doesn't support the rule-inset-cap property"; + background-color: wheat; + display: block; + text-align: center; + padding: 1rem 0; + } + } +} +``` + +```js hidden +const inset = document.getElementById("inset"); +const visibility = document.getElementById("visibility"); +const ul = document.getElementById("ul"); +const output = document.getElementById("o"); + +inset.addEventListener("input", () => { + output.innerText = + ul.style.ruleInsetCap = `${inset.value}${inset.dataset["unit"]}`; +}); + +visibility.addEventListener("change", () => { + ul.style.ruleVisibilityItems = `${visibility.value}`; +}); +``` + +#### Result + +{{EmbedLiveSample("Inner cap segments", "", "400")}} + +Select `between` from the dropdown to only paint rule segments when both adjacent grid areas contain a grid item, thereby creating interior cap segments. Then change the inset value. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{cssxref("column-rule-inset-cap")}} shorthand +- {{cssxref("row-rule-inset-cap")}} shorthand +- {{cssxref("column-rule-inset")}} shorthand +- {{cssxref("row-rule-inset")}} shorthand +- {{cssxref("rule-inset-start")}} shorthand +- {{cssxref("rule-inset")}} shorthand +- {{cssxref("rule-break")}} shorthand\ +- {{cssxref("rule-overlap")}} +- {{cssxref("rule-visibility-items")}} +- {{cssxref("rule")}} shorthand +- [CSS gaps](/en-US/docs/Web/CSS/Guides/Gaps) module diff --git a/files/en-us/web/css/reference/properties/text-decoration-inset/index.md b/files/en-us/web/css/reference/properties/text-decoration-inset/index.md index 5d2a8295148d24f..1d35c6f64bd2edb 100644 --- a/files/en-us/web/css/reference/properties/text-decoration-inset/index.md +++ b/files/en-us/web/css/reference/properties/text-decoration-inset/index.md @@ -57,11 +57,13 @@ text-decoration-inset: auto; /* One value */ text-decoration-inset: 20px; text-decoration-inset: -2rem; +text-decoration-inset: 5%; /* Two values */ text-decoration-inset: 20px 1em; text-decoration-inset: -0.5rem -1.5rem; text-decoration-inset: -2ex 1vw; +text-decoration-inset: -5% -5%; /* Global values */ text-decoration-inset: inherit; @@ -75,8 +77,8 @@ text-decoration-inset: unset; This property is specified as one or two of the following value or the keyword `auto`: -- {{cssxref("<length>")}} - - : Specifies the amount to adjust the text decoration position by. Positive values inset the text decoration (make it shorter) while negative values outset the text decoration (make it longer). If one value is specified, it applies to both the text decoration start and end points. If two values are specified, the first one applies to the text decoration start point and the second one applies to the text decoration end point. +- {{cssxref("length-percentage")}} + - : Specifies the amount to adjust the text decoration position by. Positive values inset the text decoration (make it shorter) while negative values outset the text decoration (make it longer). If one value is specified, it applies to both the text decoration start and end points. If two values are specified, the first one applies to the text decoration start point and the second one applies to the text decoration end point. Percentage values either refer to the total inline size of the {{glossary("decorating box")}} if {{cssxref("box-decoration-break")}} is set to {{cssxref("box-decoration-break", "slice", "#slice")}}, or to the inline size of each individual {{glossary("box fragment")}}, if it is set to {{cssxref("box-decoration-break", "clone", "#clone")}}. - `auto` - : The browser chooses a start and end inset amount to ensure that, if two decorated text boxes appear side-by-side, the appearance of a gap is created between their text decorations so they do not appear to have a single text decoration. @@ -86,7 +88,10 @@ By default, an element's text decoration, as set by the {{cssxref("text-decorati The `text-decoration-inset` property allows you to adjust the start and/or end points of a text container's text decoration. This is useful for creating effects where you want the text decoration to be inset or outset from the text itself, or shifted in position. See [Basic use cases](#basic_use_cases) for an example of each. -A single `` value will set the inset (if positive) or outset (if negative) on the start and end positions of the text decoration. To set the start and end positions separately, you can use two `` values — the first one applies to the start position of the text decoration and the second one applies to the end. +A single `` value will set the inset (if positive) or outset (if negative) on the start and end positions of the text decoration. To set the start and end positions separately, you can use two `` values — the first one applies to the start position of the text decoration and the second one applies to the end. + +> [!NOTE] +> A percentage value depends on the value of {{cssxref("box-decoration-break")}}, if it is set to `slice` (the initial value) it refers to the inline size of the decorating box or if it is set to `clone` it refers to each individual box fragment. The `text-decoration-inset` property can also take the `auto` keyword. This causes the browser to inset the text decoration start and end points to ensure that, if two decorated text boxes appear side-by-side, they do not appear to have a single text decoration. The `auto` value is particularly important when rendering Chinese text, where underlining is used to [punctuate proper nouns](https://www.w3.org/International/clreq/#id88), and adjacent proper nouns should have separate underlines. See [Effect of the `auto` value](#effect_of_the_auto_value) for an example. diff --git a/files/en-us/web/javascript/guide/using_promises/index.md b/files/en-us/web/javascript/guide/using_promises/index.md index df854a7cb07e7cc..18fc8a49cb27f0d 100644 --- a/files/en-us/web/javascript/guide/using_promises/index.md +++ b/files/en-us/web/javascript/guide/using_promises/index.md @@ -483,7 +483,7 @@ doSomething(() => { console.log(value); // 1 or 2? ``` -On the other hand, promises are a form of [inversion of control](https://en.wikipedia.org/wiki/Inversion_of_control) — the API implementor does not control when the callback gets called. Instead, the job of maintaining the callback queue and deciding when to call the callbacks is delegated to the promise implementation, and both the API user and API developer automatically gets strong semantic guarantees, including: +On the other hand, promises are a form of [inversion of control](https://en.wikipedia.org/wiki/Inversion_of_control) — the API implementor does not control when the callback gets called. Instead, the job of maintaining the callback queue and deciding when to call the callbacks is delegated to the promise implementation, and both the API user and API developer automatically get strong semantic guarantees, including: - Callbacks added with [`then()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) will never be invoked before the [completion of the current run](/en-US/docs/Web/JavaScript/Reference/Execution_model#run-to-completion) of the JavaScript event loop. - These callbacks will be invoked even if they were added _after_ the success or failure of the asynchronous operation that the promise represents. diff --git a/files/en-us/web/svg/reference/element/script/index.md b/files/en-us/web/svg/reference/element/script/index.md index 6f9b0ac73a026f0..4ca2f94f39d835c 100644 --- a/files/en-us/web/svg/reference/element/script/index.md +++ b/files/en-us/web/svg/reference/element/script/index.md @@ -21,7 +21,7 @@ The **`