repo_id
stringlengths
22
103
file_path
stringlengths
41
147
content
stringlengths
181
193k
__index_level_0__
int64
0
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/webkit_extensions/index.md
--- title: "-webkit-prefixed CSS extensions" slug: Web/CSS/WebKit_Extensions page-type: landing-page status: - non-standard --- {{CSSRef}} User agents based on WebKit or Blink, such as Safari and Chrome, support several special extensions to [CSS](/en-US/docs/Web/CSS). These extensions are prefixed with `-webkit-`. ## -webkit-prefixed properties without standard equivalents > **Note:** Avoid using on websites. These properties will only work in WebKit- or Blink-based browsers except where specified. ### A-C - {{CSSxRef("-webkit-app-region")}} - {{CSSxRef("-webkit-border-horizontal-spacing")}} - {{CSSxRef("-webkit-border-vertical-spacing")}} - {{CSSxRef("-webkit-box-reflect")}} (supported with `-webkit-` by every browser, for compatibility reasons) - {{CSSxRef("-webkit-column-axis")}} - {{CSSxRef("-webkit-column-progression")}} - {{CSSxRef("-webkit-cursor-visibility")}} ### D-I - {{CSSxRef("font-smooth", "-webkit-font-smoothing")}} - {{CSSxRef("-webkit-hyphenate-limit-after")}} - {{CSSxRef("-webkit-hyphenate-limit-before")}} - {{CSSxRef("-webkit-hyphenate-limit-lines")}} ### L - {{CSSxRef("-webkit-line-align")}} - {{CSSxRef("-webkit-line-box-contain")}} - {{CSSxRef("-webkit-line-clamp")}} - {{CSSxRef("-webkit-line-grid")}} - {{CSSxRef("-webkit-line-snap")}} - {{CSSxRef("-webkit-locale")}} - {{CSSxRef("-webkit-logical-height")}} - {{CSSxRef("-webkit-logical-width")}} ### M - {{CSSxRef("-webkit-margin-after")}} - {{CSSxRef("-webkit-margin-before")}} - {{CSSxRef("-webkit-mask-attachment")}} - {{CSSxRef("-webkit-mask-box-image-outset")}} - {{CSSxRef("-webkit-mask-box-image-repeat")}} - {{CSSxRef("-webkit-mask-box-image-slice")}} - {{CSSxRef("-webkit-mask-box-image-source")}} - {{CSSxRef("-webkit-mask-box-image-width")}} - {{CSSxRef("-webkit-mask-box-image")}} - {{cssxref("-webkit-mask-composite")}} - {{CSSxRef("-webkit-mask-position-x")}} (supported with `-webkit-` by every browser, for compatibility reasons) - {{CSSxRef("-webkit-mask-position-y")}} (supported with `-webkit-` by every browser, for compatibility reasons) - {{CSSxRef("-webkit-mask-repeat-x")}} (also supported without prefix) - {{CSSxRef("-webkit-mask-repeat-y")}} (also supported without prefix) - {{CSSxRef("-webkit-mask-source-type")}} - {{CSSxRef("-webkit-max-logical-height")}} - {{CSSxRef("-webkit-max-logical-width")}} - {{CSSxRef("-webkit-min-logical-height")}} - {{CSSxRef("-webkit-min-logical-width")}} ### N-R - {{CSSxRef("-webkit-nbsp-mode")}} - {{CSSxRef("-webkit-perspective-origin-x")}} - {{CSSxRef("-webkit-perspective-origin-y")}} - {{CSSxRef("-webkit-rtl-ordering")}} ### T - {{CSSxRef("-webkit-tap-highlight-color")}} - {{CSSxRef("-webkit-text-decoration-skip")}} - {{CSSxRef("-webkit-text-decorations-in-effect")}} - {{CSSxRef("-webkit-text-fill-color")}} - {{CSSxRef("-webkit-text-security")}} - {{CSSxRef("-webkit-text-stroke-color")}} - {{CSSxRef("-webkit-text-stroke-width")}} - {{CSSxRef("-webkit-text-stroke")}} - {{CSSxRef("-webkit-text-zoom")}} - {{cssxref("-webkit-touch-callout")}} - {{CSSxRef("-webkit-transform-origin-x")}} - {{CSSxRef("-webkit-transform-origin-y")}} - {{CSSxRef("-webkit-transform-origin-z")}} ### U-Z - {{CSSxRef("-webkit-user-drag")}} - {{CSSxRef("-webkit-user-modify")}} ## -webkit-prefixed properties with standard equivalents Several old `-webkit-`prefixed properties have standard equivalents. Even if the name and syntax may be different, they shouldn't be used anymore at all. For each of them, use the standard equivalent provided. ### A-B - `-webkit-border-after` - : Use the standard {{CSSxRef("border-block-end")}} property instead. - `-webkit-border-after-color` - : Use the standard {{CSSxRef("border-block-end-color")}} property instead. - `-webkit-border-after-style` - : Use the standard {{CSSxRef("border-block-end-style")}} property instead. - `-webkit-border-after-width` - : Use the standard {{CSSxRef("border-block-end-width")}} property instead. - `-webkit-border-before` - : Use the standard {{CSSxRef("border-block-start")}} property instead. - `-webkit-border-before-color` - : Use the standard {{CSSxRef("border-block-start-color")}} property instead. - `-webkit-border-before-style` - : Use the standard {{CSSxRef("border-block-start-style")}} property instead. - `-webkit-border-before-width` - : Use the standard {{CSSxRef("border-block-start-width")}} property instead. - `-webkit-border-end` - : Use the standard {{CSSxRef("border-inline-end")}} property instead. - `-webkit-border-end-color` - : Use the standard {{CSSxRef("border-inline-end-color")}} property instead. - `-webkit-border-end-style` - : Use the standard {{CSSxRef("border-inline-end-style")}} property instead. - `-webkit-border-end-width` - : Use the standard {{CSSxRef("border-inline-end-width")}} property instead. - `-webkit-border-start` - : Use the standard {{CSSxRef("border-inline-start")}} property instead. - `-webkit-border-start-color` - : Use the standard {{CSSxRef("border-inline-start-color")}} property instead. - `-webkit-border-start-style` - : Use the standard {{CSSxRef("border-inline-start-style")}} property instead. - `-webkit-border-start-width` - : Use the standard {{CSSxRef("border-inline-start-width")}} property instead. - `-webkit-box-align` - : Use the [CSS flexible box layout](/en-US/docs/Web/CSS/CSS_flexible_box_layout) with the standard {{CSSxRef("align-items")}} property instead. - `-webkit-box-direction` - : Use the [CSS flexible box layout](/en-US/docs/Web/CSS/CSS_flexible_box_layout) with the standard {{CSSxRef("flex-direction")}} property instead. - {{CSSxRef("box-flex-group", "-webkit-box-flex-group")}} - : Use the [CSS flexible box layout](/en-US/docs/Web/CSS/CSS_flexible_box_layout) with the standard {{cssxref("flex-basis")}}, {{cssxref("flex-grow")}}, and {{cssxref("flex-shrink")}} properties instead. - `-webkit-box-flex` - : Use the [CSS flexible box layout](/en-US/docs/Web/CSS/CSS_flexible_box_layout) with the standard {{CSSxRef("flex-grow")}} property instead. - `-webkit-box-lines` - : Use the [CSS flexible box layout](/en-US/docs/Web/CSS/CSS_flexible_box_layout) with the standard {{CSSxRef("flex-flow")}} property instead. - `-webkit-box-ordinal-group` - : Use the [CSS flexible box layout](/en-US/docs/Web/CSS/CSS_flexible_box_layout) with the standard {{CSSxRef("order")}} property instead. - `-webkit-box-orient` - : Use the [CSS flexible box layout](/en-US/docs/Web/CSS/CSS_flexible_box_layout) with the standard {{CSSxRef("flex-direction")}} property instead. - `-webkit-box-pack` - : Use the [CSS flexible box layout](/en-US/docs/Web/CSS/CSS_flexible_box_layout) with the standard {{CSSxRef("justify-content")}} property instead. ### C-I - `-webkit-column-break-after` - : Use the [CSS multicolumn layout](/en-US/docs/Web/CSS/CSS_multicol_layout) with the standard {{cssxref("break-after")}} property instead. - `-webkit-column-break-before` - : Use the [CSS multicolumn layout](/en-US/docs/Web/CSS/CSS_multicol_layout) with the standard {{cssxref("break-before")}} property instead. - `-webkit-column-break-inside` - : Use the [CSS multicolumn layout](/en-US/docs/Web/CSS/CSS_multicol_layout) with the standard {{cssxref("break-inside")}} property instead. - `-webkit-hyphenate-character` - : Use the standard {{cssxref("hyphenate-character")}} property instead. - `-webkit-initial-letter` - : Use the standard {{cssxref("initial-letter")}} property instead. ### J-Z - `webkit-margin-end` - : Use the standard {{CSSxRef("margin-block-end")}} property instead. - `-webkit-margin-start` - : Use the standard {{CSSxRef("margin-block-start")}} property instead. - `-webkit-padding-after` - : Use the standard {{CSSxRef("padding-block-end")}} property instead. - `-webkit-padding-before` - : Use the standard {{CSSxRef("padding-block-start")}} property instead. - `-webkit-padding-end` - : Use the standard {{CSSxRef("padding-inline-end")}} property instead. - `-webkit-padding-start` - : Use the standard {{CSSxRef("padding-inline-start")}} property instead. ## Pseudo-classes - {{CSSxRef(":animating-full-screen-transition", ":-webkit-animating-full-screen-transition")}} - {{CSSxRef(":is", ":-webkit-any()")}} - {{CSSxRef(":any-link", ":-webkit-any-link")}}\* - {{CSSxRef(":autofill",":-webkit-autofill")}} - {{CSSxRef(":autofill-strong-password",":-webkit-autofill-strong-password")}} - {{CSSxRef(":drag",":-webkit-drag")}} - {{CSSxRef(":full-page-media",":-webkit-full-page-media")}} - {{CSSxRef(":full-screen", ":-webkit-full-screen")}}\* - {{CSSxRef(":full-screen-ancestor",":-webkit-full-screen-ancestor")}} - {{CSSxRef(":full-screen-document",":-webkit-full-screen-document")}} - {{CSSxRef(":full-screen-controls-hidden",":-webkit-full-screen-controls-hidden")}} \* Now standard. > **Note:** If there is an invalid pseudo-class within in a chain or group of selectors, the whole selector list is invalid. ## Pseudo-elements For web-compatibility reasons, Blink, WebKit, and Gecko browsers treat all pseudo-elements starting with `::-webkit-` as valid. - {{CSSxRef("::file-selector-button","::-webkit-file-upload-button")}}\* - {{CSSxRef("::-webkit-inner-spin-button", "::-webkit-inner-spin-button")}} - {{CSSxRef("::placeholder", "::-webkit-input-placeholder")}} - {{CSSxRef("::-webkit-meter-bar", "::-webkit-meter-bar")}} - {{CSSxRef("::-webkit-meter-even-less-good-value", "::-webkit-meter-even-less-good-value")}} - {{CSSxRef("::-webkit-meter-inner-element", "::-webkit-meter-inner-element")}} - {{CSSxRef("::-webkit-meter-optimum-value", "::-webkit-meter-optimum-value")}} - {{CSSxRef("::-webkit-meter-suboptimum-value", "::-webkit-meter-suboptimum-value")}} - {{CSSxRef("::-webkit-progress-bar", "::-webkit-progress-bar")}} - {{CSSxRef("::-webkit-progress-inner-element", "::-webkit-progress-inner-element")}} - {{CSSxRef("::-webkit-progress-value", "::-webkit-progress-value")}} - {{CSSxRef("::-webkit-search-cancel-button", "::-webkit-search-cancel-button")}} - {{CSSxRef("::-webkit-search-results-button", "::-webkit-search-results-button")}} - {{CSSxRef("::-webkit-slider-runnable-track", "::-webkit-slider-runnable-track")}} - {{CSSxRef("::-webkit-slider-thumb", "::-webkit-slider-thumb")}} \* Now standard. > **Note:** Generally, if there is an invalid pseudo-element or pseudo-class within in a chain or group of selectors, the whole selector list is invalid. If a pseudo-element (but not pseudo-class) has a -webkit- prefix, As of Firefox 63, Blink, WebKit and Gecko browsers assume it is valid, not invalidating the selector list. ## Media features - {{CSSxRef("@media/-webkit-animation", "-webkit-animation")}} - {{CSSxRef("@media/-webkit-device-pixel-ratio", "-webkit-device-pixel-ratio")}} - {{CSSxRef("@media/-webkit-transform-2d", "-webkit-transform-2d")}} - {{CSSxRef("@media/-webkit-transform-3d", "-webkit-transform-3d")}} - {{CSSxRef("@media/-webkit-transition", "-webkit-transition")}} ## See also - [Vendor Prefix](/en-US/docs/Glossary/Vendor_Prefix) glossary entry - [Mozilla vendor-prefixed CSS extensions](/en-US/docs/Web/CSS/Mozilla_Extensions) - [Styling Form Controls on the WebKit Trac](https://trac.webkit.org/wiki/Styling%20Form%20Controls)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/view-timeline/index.md
--- title: view-timeline slug: Web/CSS/view-timeline page-type: css-shorthand-property status: - experimental browser-compat: css.properties.view-timeline --- {{CSSRef}}{{SeeCompatTable}} The **`view-timeline`** [CSS](/en-US/docs/Web/CSS) [shorthand property](/en-US/docs/Web/CSS/Shorthand_properties) is used to define a _named view progress timeline_, which is progressed through based on the change in visibility of an element (known as the _subject_) inside a scrollable element (_scroller_). `view-timeline` is set on the subject. The visibility of the subject inside the scroller is tracked — by default, the timeline is at 0% when the subject is first visible at one edge of the scroller and 100% when it reaches the opposite edge. `view-timeline` can contain two constituent values — a name for the named view progress timeline and an optional scroll axis value. The name is then referenced in an [`animation-timeline`](/en-US/docs/Web/CSS/animation-timeline) declaration to indicate the element that will be animated as the timeline progresses. This can be the subject element, but it doesn't have to be — you can animate a different element as the subject moves through the scrolling area. > **Note:** If the scroller does not overflow its container in the axis dimension or if the overflow is hidden or clipped, no timeline will be created. ## Constituent properties This property is a shorthand for the following CSS properties: - [`view-timeline-name`](/en-US/docs/Web/CSS/view-timeline-name) - [`view-timeline-axis`](/en-US/docs/Web/CSS/view-timeline-axis) ## Syntax ```css /* two values: one each for view-timeline-name and view-timeline-axis */ view-timeline: --custom_name_for_timeline block; view-timeline: --custom_name_for_timeline inline; view-timeline: --custom_name_for_timeline y; view-timeline: --custom_name_for_timeline x; view-timeline: none block; view-timeline: none inline; view-timeline: none y; view-timeline: none x; /* one value: view-timeline-name */ view-timeline: none; view-timeline: --custom_name_for_timeline; ``` The `view-timeline` shorthand property can be applied to a container element as a combination of the `<view-timeline-name>` and `<view-timeline-axis>` values. At least one of the values must be specified. If both the values are specified, the order followed must be the `<view-timeline-name>` value followed by the `<view-timeline-axis>` value. > **Note:** `<view-timeline-name>`s must be [`<dashed-ident>`](/en-US/docs/Web/CSS/dashed-ident) values, which means they must start with `--`. This helps avoid name clashes with standard CSS keywords. ### Values - `<view-timeline-name>` - : See [`view-timeline-name`](/en-US/docs/Web/CSS/view-timeline-name). - `<view-timeline-axis>` - : See [`view-timeline-axis`](/en-US/docs/Web/CSS/view-timeline-axis). The default value is `block`. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Creating a named view progress timeline A view progress timeline named `--subjectReveal` is defined using the `view-timeline` property on a subject element with a `class` of `animation`. This is then set as the timeline for the same element using `animation-timeline: --subjectReveal`. The result is that the subject element animates as it moves upwards through the document as it is scrolled. #### HTML The HTML for the example is shown below. ```html <div class="content"> <h1>Content</h1> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Risus quis varius quam quisque id. Et ligula ullamcorper malesuada proin libero nunc consequat interdum varius. Elit ullamcorper dignissim cras tincidunt lobortis feugiat vivamus at augue. </p> <p> Dolor sed viverra ipsum nunc aliquet. Sed sed risus pretium quam vulputate dignissim. Tortor aliquam nulla facilisi cras. A erat nam at lectus urna duis convallis convallis. Nibh ipsum consequat nisl vel pretium lectus. Sagittis aliquam malesuada bibendum arcu vitae elementum. Malesuada bibendum arcu vitae elementum curabitur vitae nunc sed velit. </p> <div class="subject animation"></div> <p> Adipiscing enim eu turpis egestas pretium aenean pharetra magna ac. Arcu cursus vitae congue mauris rhoncus aenean vel. Sit amet cursus sit amet dictum. Augue neque gravida in fermentum et. Gravida rutrum quisque non tellus orci ac auctor augue mauris. Risus quis varius quam quisque id diam vel quam elementum. Nibh praesent tristique magna sit amet purus gravida quis. Duis ultricies lacus sed turpis tincidunt id aliquet. In egestas erat imperdiet sed euismod nisi. Eget egestas purus viverra accumsan in nisl nisi scelerisque. Netus et malesuada fames ac. </p> </div> ``` #### CSS The `subject` element and its containing `content` element are styled minimally, and the text content is given some basic font settings: ```css .subject { width: 300px; height: 200px; margin: 0 auto; background-color: deeppink; } .content { width: 75%; max-width: 800px; margin: 0 auto; } p, h1 { font-family: Arial, Helvetica, sans-serif; } h1 { font-size: 3rem; } p { font-size: 1.5rem; line-height: 1.5; } ``` The `<div>` with the class of `subject` is also given a class of `animation` — this is where `view-timeline` is set to define a named view progress timeline. It is also given an `animation-timeline` name with the same value to declare that this will be the element animated as the view progress timeline is progressed. Last, an animation is specified on the element that animates its opacity and scale, causing it to fade in and size up as it moves up the scroller. ```css .animation { view-timeline: --subjectReveal block; animation-timeline: --subjectReveal; animation-name: appear; animation-fill-mode: both; animation-duration: 1ms; /* Firefox requires this to apply the animation */ } @keyframes appear { from { opacity: 0; transform: scaleX(0); } to { opacity: 1, transform: scaleX(1); } } ``` #### Result Scroll to see the subject element being animated. {{EmbedLiveSample("Creating a named view progress timeline", "100%", "480px")}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [`animation-timeline`](/en-US/docs/Web/CSS/animation-timeline) - {{cssxref("timeline-scope")}} - [`view-timeline-axis`](/en-US/docs/Web/CSS/view-timeline-axis), [`view-timeline-name`](/en-US/docs/Web/CSS/view-timeline-name) - [CSS scroll-driven animations](/en-US/docs/Web/CSS/CSS_scroll-driven_animations)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/revert-layer/index.md
--- title: revert-layer slug: Web/CSS/revert-layer page-type: css-keyword status: - experimental browser-compat: css.types.global_keywords.revert-layer --- {{CSSRef}}{{SeeCompatTable}} The **`revert-layer`** CSS keyword rolls back the value of a property in a {{cssxref("@layer", "cascade layer")}} to the value of the property in a CSS rule matching the element in a previous cascade layer. The value of the property with this keyword is recalculated as if no rules were specified on the target element in the current cascade layer. If there is no other cascade layer to revert to for the matching CSS rule, the property value rolls back to the {{cssxref("computed_value", "computed value")}} derived from the current layer. Furthermore, if there is no matching CSS rule in the current layer, the property value for the element rolls back to the style defined in a previous [style origin](/en-US/docs/Glossary/Style_origin). This keyword can be applied to any CSS property, including the CSS shorthand property {{cssxref("all")}}. ## Revert-layer vs. revert The `revert-layer` keyword lets you rollback styles to the ones specified in previous cascade layers. All cascade layers exist in the [author origin](/en-US/docs/Glossary/Style_origin). The {{cssxref("revert")}} keyword, in comparison, lets you remove styles applied in the author origin and roll back to styles in user origin or user-agent origin. The `revert-layer` keyword is ideally meant for applying on properties inside a layer. However, if the `revert-layer` keyword is set on a property outside a layer, the value of the property will roll back to the default value established by the user agent's stylesheet (or by user styles, if any exist). So in this scenario, the `revert-layer` keyword behaves like the {{cssxref("revert")}} keyword. ## Examples ### Default cascade layer behavior In the example below, two cascade layers are defined in the CSS, `base` and `special`. By default, rules in the `special` layer will override competing rules in the `base` layer because `special` is listed after `base` in the `@layer` declaration statement. #### HTML ```html <p>This example contains a list.</p> <ul> <li class="item feature">Item one</li> <li class="item">Item two</li> <li class="item">Item three</li> </ul> ``` #### CSS ```css @layer base, special; @layer special { .item { color: red; } } @layer base { .item { color: blue; } .feature { color: green; } } ``` #### Result {{EmbedLiveSample('Default_cascade_layer_behavior')}} All the `<li>` elements match the `item` rule in the `special` layer and are red. This is the default cascade layer behavior, where rules in the `special` layer take precedence over rules in the `base` layer. ### Revert to style in previous cascade layer Let's examine how the `revert-layer` keyword changes the default cascade layer behavior. For this example, the `special` layer contains an additional `feature` rule targeting the first `<li>` element. The `color` property in this rule is set to `revert-layer`. #### HTML ```html <p>This example contains a list.</p> <ul> <li class="item feature">Item one</li> <li class="item">Item two</li> <li class="item">Item three</li> </ul> ``` #### CSS ```css @layer base, special; @layer special { .item { color: red; } .feature { color: revert-layer; } } @layer base { .item { color: blue; } .feature { color: green; } } ``` #### Result {{EmbedLiveSample('Revert_to_style_in_previous_cascade_layer')}} With `color` set to `revert-layer`, the `color` property value rolls back to the value in the matching `feature` rule in the previous layer `base`, and so 'Item one' is now green. ### Revert to style in previous origin This example shows the `revert-layer` keyword behavior when there is no cascade layer to revert to _and_ there is no matching CSS rule in the current layer to inherit the property value. #### HTML ```html <p>This example contains a list.</p> <ul> <li class="item feature">Item one</li> <li class="item">Item two</li> <li class="item">Item three</li> </ul> ``` #### CSS ```css @layer base { .item { color: revert-layer; } } ``` #### Result {{EmbedLiveSample('Revert_to_style_in_previous_origin')}} The style for all `<li>` elements rolls back to the defaults in the user-agent origin. ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref("initial")}}: Sets a property to its initial value - {{cssxref("inherit")}}: Sets an element's property the same as its parent - {{cssxref("revert")}}: Resets a property to the value established by the user-agent stylesheet (or user styles if any exist) - {{cssxref("unset")}}: Sets a property to its inherited value if the property inherits or to its initial value if the property does not inherit - {{cssxref("all")}}: Resets all properties to their initial, inherited, reverted, or unset state at once
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/min-inline-size/index.md
--- title: min-inline-size slug: Web/CSS/min-inline-size page-type: css-property browser-compat: css.properties.min-inline-size --- {{CSSRef}} The **`min-inline-size`** [CSS](/en-US/docs/Web/CSS) property defines the horizontal or vertical minimal size of an element's block, depending on its writing mode. It corresponds to either the {{cssxref("min-width")}} or the {{cssxref("min-height")}} property, depending on the value of {{cssxref("writing-mode")}}. {{EmbedInteractiveExample("pages/css/min-inline-size.html")}} ## Syntax ```css /* <length> values */ min-inline-size: 100px; min-inline-size: 5em; /* <percentage> values */ min-inline-size: 10%; /* Keyword values */ min-inline-size: max-content; min-inline-size: min-content; min-inline-size: fit-content; min-inline-size: fit-content(20em); /* Global values */ min-inline-size: inherit; min-inline-size: initial; min-inline-size: revert; min-inline-size: revert-layer; min-inline-size: unset; ``` If the writing mode is vertically oriented, the value of `min-inline-size` relates to the minimum height of the element; otherwise, it relates to the minimum width of the element. A related property is {{cssxref("min-block-size")}}, which defines the other dimension of the element. ### Values The `min-inline-size` property takes the same values as the {{cssxref("min-width")}} and {{cssxref("min-height")}} properties. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Setting minimum inline size for vertical text #### HTML ```html <p class="exampleText">Example text</p> ``` #### CSS ```css .exampleText { writing-mode: vertical-rl; background-color: yellow; block-size: 5%; min-inline-size: 200px; } ``` #### Result {{EmbedLiveSample("Setting_minimum_inline_size_for_vertical_text")}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - The mapped physical properties: {{cssxref("min-width")}} and {{cssxref("min-height")}} - {{cssxref("writing-mode")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_colon_focus/index.md
--- title: ":focus" slug: Web/CSS/:focus page-type: css-pseudo-class browser-compat: css.selectors.focus --- {{CSSRef}} The **`:focus`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) represents an element (such as a form input) that has received focus. It is generally triggered when the user clicks or taps on an element or selects it with the keyboard's <kbd>Tab</kbd> key. {{EmbedInteractiveExample("pages/tabbed/pseudo-class-focus.html", "tabbed-shorter")}} > **Note:** This pseudo-class applies only to the focused element itself. Use {{CSSxRef(":focus-within")}} if you want to select an element that _contains_ a focused element. ## Syntax ```css :focus { /* ... */ } ``` ## Examples ### HTML ```html <div><input class="red-input" value="I'll be red when focused." /></div> <div><input class="blue-input" value="I'll be blue when focused." /></div> ``` ### CSS ```css .red-input:focus { background: yellow; color: red; } .blue-input:focus { background: yellow; color: blue; } ``` ### Result {{EmbedLiveSample("Examples")}} ## Accessibility concerns Make sure the visual focus indicator can be seen by people with low vision. This will also benefit anyone use a screen in a brightly lit space (like outside in the sun). [WCAG 2.1 SC 1.4.11 Non-Text Contrast](https://www.w3.org/WAI/WCAG21/Understanding/non-text-contrast.html) requires that the visual focus indicator be at least 3 to 1. - Accessible Visual Focus Indicators: [Give Your Site Some Focus! Tips for Designing Useful and Usable Focus Indicators](https://www.deque.com/blog/give-site-focus-tips-designing-usable-focus-indicators/) ### `:focus { outline: none; }` Never just remove the focus outline (visible focus indicator) without replacing it with a focus outline that will pass [WCAG 2.1 SC 1.4.11 Non-Text Contrast](https://www.w3.org/WAI/WCAG21/Understanding/non-text-contrast.html). - Quick Tip: [Never remove CSS outlines](https://www.a11yproject.com/posts/never-remove-css-outlines/) ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{CSSxRef(":focus-visible")}} - {{CSSxRef(":focus-within")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/scroll-margin-bottom/index.md
--- title: scroll-margin-bottom slug: Web/CSS/scroll-margin-bottom page-type: css-property browser-compat: css.properties.scroll-margin-bottom --- {{CSSRef}} The `scroll-margin-bottom` property defines the bottom margin of the scroll snap area that is used for snapping this box to the snapport. The scroll snap area is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the scroll container's coordinate space), then adding the specified outsets. {{EmbedInteractiveExample("pages/css/scroll-margin-bottom.html")}} ## Syntax ```css /* <length> values */ scroll-margin-bottom: 10px; scroll-margin-bottom: 1em; /* Global values */ scroll-margin-bottom: inherit; scroll-margin-bottom: initial; scroll-margin-bottom: revert; scroll-margin-bottom: revert-layer; scroll-margin-bottom: unset; ``` ### Values - {{CSSXref("&lt;length&gt;")}} - : An outset from the bottom edge of the scroll container. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS scroll snap](/en-US/docs/Web/CSS/CSS_scroll_snap) - [Well-controlled scrolling with CSS scroll snap](https://web.dev/articles/css-scroll-snap)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_colon_seeking/index.md
--- title: ":seeking" slug: Web/CSS/:seeking page-type: css-pseudo-class browser-compat: css.selectors.seeking --- {{CSSRef}} The **`:seeking`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) selector represents an element that is playable, such as {{htmlelement("audio")}} or {{htmlelement("video")}}, when the playable element is seeking a playback position in the media resource. A resource is considered to be seeking if the user has requested playback of a specific position in the media resource, but the media element has not yet reached that position. Seeking is different from {{cssxref(":buffering")}} in that the media element is not currently loading data, but is instead skipping to a new position in the media resource. For more information, see the [Media buffering, seeking, and time ranges](/en-US/docs/Web/Media/Audio_and_video_delivery/buffering_seeking_time_ranges#seekable) guide. ## Syntax ```css :seeking { /* ... */ } ``` ## Examples ### CSS ```css :seeking { outline: 5px solid red; } video:seeking { outline: 5px solid blue; } ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref(":buffering")}} - {{cssxref(":muted")}} - {{cssxref(":paused")}} - {{cssxref(":playing")}} - {{cssxref(":stalled")}} - {{cssxref(":volume-locked")}} - [CSS selectors](/en-US/docs/Web/CSS/CSS_selectors)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/border-inline-end-color/index.md
--- title: border-inline-end-color slug: Web/CSS/border-inline-end-color page-type: css-property browser-compat: css.properties.border-inline-end-color --- {{CSSRef}} The **`border-inline-end-color`** [CSS](/en-US/docs/Web/CSS) property defines the color of the logical inline-end border of an element, which maps to a physical border color depending on the element's writing mode, directionality, and text orientation. It corresponds to the {{cssxref("border-top-color")}}, {{cssxref("border-right-color")}}, {{cssxref("border-bottom-color")}}, or {{cssxref("border-left-color")}} property depending on the values defined for {{cssxref("writing-mode")}}, {{cssxref("direction")}}, and {{cssxref("text-orientation")}}. {{EmbedInteractiveExample("pages/css/border-inline-end-color.html")}} ## Syntax ```css border-inline-end-color: rebeccapurple; border-inline-end-color: #663399; /* Global values */ border-inline-end-color: inherit; border-inline-end-color: initial; border-inline-end-color: revert; border-inline-end-color: revert-layer; border-inline-end-color: unset; ``` Related properties are {{cssxref("border-block-start-color")}}, {{cssxref("border-block-end-color")}}, and {{cssxref("border-inline-start-color")}}, which define the other border colors of the element. ### Values - {{CSSXref("&lt;color&gt;")}} - : The color of the border. ## Formal definition {{CSSInfo}} ## Formal syntax {{csssyntax}} ## Examples ### HTML ```html <div> <p class="exampleText">Example text</p> </div> ``` ### CSS ```css div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 10px solid blue; border-inline-end-color: red; } ``` {{EmbedLiveSample("Examples", 140, 140)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS Logical Properties and Values](/en-US/docs/Web/CSS/CSS_logical_properties_and_values) - This property maps to one of the physical border properties: {{cssxref("border-top-color")}}, {{cssxref("border-right-color")}}, {{cssxref("border-bottom-color")}}, or {{cssxref("border-left-color")}}. - {{cssxref("writing-mode")}}, {{cssxref("direction")}}, {{cssxref("text-orientation")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/text-align/index.md
--- title: text-align slug: Web/CSS/text-align page-type: css-property browser-compat: css.properties.text-align --- {{CSSRef}} The **`text-align`** [CSS](/en-US/docs/Web/CSS) property sets the horizontal alignment of the inline-level content inside a block element or table-cell box. This means it works like {{cssxref("vertical-align")}} but in the horizontal direction. {{EmbedInteractiveExample("pages/css/text-align.html")}} ## Syntax ```css /* Keyword values */ text-align: start; text-align: end; text-align: left; text-align: right; text-align: center; text-align: justify; text-align: justify-all; text-align: match-parent; /* Block alignment values (Non-standard syntax) */ text-align: -moz-center; text-align: -webkit-center; /* Global values */ text-align: inherit; text-align: initial; text-align: revert; text-align: revert-layer; text-align: unset; ``` The `text-align` property is specified in one of the following ways: - Using the keyword values `start`, `end`, `left`, `right`, `center`, `justify`, `justify-all`, or `match-parent`. - Using a `<string>` value only, in which case the other value defaults to `right`. - Using both a keyword value and a [`<string>`](#string) value. ### Values - `start` - : The same as `left` if direction is left-to-right and `right` if direction is right-to-left. - `end` - : The same as `right` if direction is left-to-right and `left` if direction is right-to-left. - `left` {{deprecated_inline}} {{non-standard_inline}} - : The inline contents are aligned to the left edge of the line box. - `right` {{deprecated_inline}} {{non-standard_inline}} - : The inline contents are aligned to the right edge of the line box. - `center` {{deprecated_inline}} {{non-standard_inline}} - : The inline contents are centered within the line box. - `justify` - : The inline contents are justified. Text should be spaced to line up its left and right edges to the left and right edges of the line box, except for the last line. - `justify-all` {{experimental_inline}} - : Same as `justify`, but also forces the last line to be justified. - `match-parent` - : Similar to `inherit`, but the values `start` and `end` are calculated according to the parent's {{cssxref("direction")}} and are replaced by the appropriate `left` or `right` value. ## Accessibility concerns The inconsistent spacing between words created by justified text can be problematic for people with cognitive concerns such as Dyslexia. - [MDN Understanding WCAG, Guideline 1.4 explanations](/en-US/docs/Web/Accessibility/Understanding_WCAG/Perceivable#guideline_1.4_make_it_easier_for_users_to_see_and_hear_content_including_separating_foreground_from_background) - [Understanding Success Criterion 1.4.8 | Understanding WCAG 2.0](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-visual-presentation.html) ## Formal definition {{CSSInfo}} ## Formal syntax {{csssyntax}} ## Examples ### Start alignment #### HTML ```html <p class="example"> Integer elementum massa at nulla placerat varius. Suspendisse in libero risus, in interdum massa. Vestibulum ac leo vitae metus faucibus gravida ac in neque. Nullam est eros, suscipit sed dictum quis, accumsan a ligula. </p> ``` #### CSS ```css .example { text-align: start; border: solid; } ``` #### Result {{EmbedLiveSample("Start_alignment","100%","100%")}} ### Centered text #### HTML ```html <p class="example"> Integer elementum massa at nulla placerat varius. Suspendisse in libero risus, in interdum massa. Vestibulum ac leo vitae metus faucibus gravida ac in neque. Nullam est eros, suscipit sed dictum quis, accumsan a ligula. </p> ``` #### CSS ```css .example { text-align: center; border: solid; } ``` #### Result {{EmbedLiveSample("Centered_text","100%","100%")}} ### Example using "justify" #### HTML ```html <p class="example"> Integer elementum massa at nulla placerat varius. Suspendisse in libero risus, in interdum massa. Vestibulum ac leo vitae metus faucibus gravida ac in neque. Nullam est eros, suscipit sed dictum quis, accumsan a ligula. </p> ``` #### CSS ```css .example { text-align: justify; border: solid; } ``` #### Result {{EmbedLiveSample('Example using "justify"',"100%","100%")}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{Cssxref("margin","margin: auto")}}, {{Cssxref("margin-left","margin-left: auto")}}, {{Cssxref("vertical-align")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/border-bottom-width/index.md
--- title: border-bottom-width slug: Web/CSS/border-bottom-width page-type: css-property browser-compat: css.properties.border-bottom-width --- {{CSSRef}} The **`border-bottom-width`** [CSS](/en-US/docs/Web/CSS) property sets the width of the bottom border of an element. {{EmbedInteractiveExample("pages/css/border-bottom-width.html")}} ## Syntax ```css /* Keyword values */ border-bottom-width: thin; border-bottom-width: medium; border-bottom-width: thick; /* <length> values */ border-bottom-width: 10em; border-bottom-width: 3vmax; border-bottom-width: 6px; /* Global keywords */ border-bottom-width: inherit; border-bottom-width: initial; border-bottom-width: revert; border-bottom-width: revert-layer; border-bottom-width: unset; ``` ### Values - `<line-width>` - : Defines the width of the border, either as an explicit nonnegative {{cssxref("&lt;length&gt;")}} or a keyword. If it's a keyword, it must be one of the following values: - `thin` - `medium` - `thick` > **Note:** Because the specification doesn't define the exact thickness denoted by each keyword, the precise result when using one of them is implementation-specific. Nevertheless, they always follow the pattern `thin ≤ medium ≤ thick`, and the values are constant within a single document. ## Formal definition {{CSSInfo}} ## Formal syntax {{csssyntax}} ## Examples ### Comparing bottom border widths #### HTML ```html <div>Element 1</div> <div>Element 2</div> ``` #### CSS ```css div { border: 1px solid red; margin: 1em 0; } div:nth-child(1) { border-bottom-width: thick; } div:nth-child(2) { border-bottom-width: 2em; } ``` #### Result {{EmbedLiveSample('Comparing_bottom_border_widths', '100%')}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - The other border-width-related CSS properties: {{Cssxref("border-left-width")}}, {{Cssxref("border-right-width")}}, {{Cssxref("border-top-width")}}, and {{Cssxref("border-width")}}. - The other border-bottom-related CSS properties: {{Cssxref("border")}}, {{Cssxref("border-bottom")}}, {{Cssxref("border-bottom-style")}}, and {{Cssxref("border-bottom-color")}}.
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/border-bottom-style/index.md
--- title: border-bottom-style slug: Web/CSS/border-bottom-style page-type: css-property browser-compat: css.properties.border-bottom-style --- {{CSSRef}} The **`border-bottom-style`** [CSS](/en-US/docs/Web/CSS) property sets the line style of an element's bottom {{cssxref("border")}}. {{EmbedInteractiveExample("pages/css/border-bottom-style.html")}} > **Note:** The specification doesn't define how borders of different styles connect in the corners. ## Syntax ```css /* Keyword values */ border-bottom-style: none; border-bottom-style: hidden; border-bottom-style: dotted; border-bottom-style: dashed; border-bottom-style: solid; border-bottom-style: double; border-bottom-style: groove; border-bottom-style: ridge; border-bottom-style: inset; border-bottom-style: outset; /* Global values */ border-bottom-style: inherit; border-bottom-style: initial; border-bottom-style: revert; border-bottom-style: revert-layer; border-bottom-style: unset; ``` The `border-bottom-style` property is specified as a single {{cssxref("line-style")}} keyword value. ## Formal definition {{CSSInfo}} ## Formal syntax {{csssyntax}} ## Examples ### Demonstrating all border styles #### HTML ```html <table> <tr> <td class="b1">none</td> <td class="b2">hidden</td> <td class="b3">dotted</td> <td class="b4">dashed</td> </tr> <tr> <td class="b5">solid</td> <td class="b6">double</td> <td class="b7">groove</td> <td class="b8">ridge</td> </tr> <tr> <td class="b9">inset</td> <td class="b10">outset</td> </tr> </table> ``` #### CSS ```css /* Define look of the table */ table { border-width: 3px; background-color: #52e385; } tr, td { padding: 3px; } /* border-bottom-style example classes */ .b1 { border-bottom-style: none; } .b2 { border-bottom-style: hidden; } .b3 { border-bottom-style: dotted; } .b4 { border-bottom-style: dashed; } .b5 { border-bottom-style: solid; } .b6 { border-bottom-style: double; } .b7 { border-bottom-style: groove; } .b8 { border-bottom-style: ridge; } .b9 { border-bottom-style: inset; } .b10 { border-bottom-style: outset; } ``` #### Result {{ EmbedLiveSample('Demonstrating_all_border_styles', 300, 200) }} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - The other style-related border properties: {{ Cssxref("border-left-style") }}, {{ Cssxref("border-right-style") }}, {{ Cssxref("border-top-style") }}, and {{ Cssxref("border-style") }}. - The other bottom-border-related properties: {{ Cssxref("border-bottom") }}, {{ Cssxref("border-bottom-color") }}, and {{ Cssxref("border-bottom-width") }}.
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/border-bottom-left-radius/index.md
--- title: border-bottom-left-radius slug: Web/CSS/border-bottom-left-radius page-type: css-property browser-compat: css.properties.border-bottom-left-radius --- {{CSSRef}} The **`border-bottom-left-radius`** [CSS](/en-US/docs/Web/CSS) property rounds the bottom-left corner of an element by specifying the radius (or the radius of the semi-major and semi-minor axes) of the ellipse defining the curvature of the corner. {{EmbedInteractiveExample("pages/css/border-bottom-left-radius.html")}} The rounding can be a circle or an ellipse, or if one of the value is `0` no rounding is done and the corner is square. ![border-bottom-left-radius.png](border-bottom-left-radius.png) A background, being an image or a color, is clipped at the border, even a rounded one; the exact location of the clipping is defined by the value of the {{cssxref("background-clip")}} property. > **Note:** If the value of this property is not set in a {{cssxref("border-radius")}} shorthand property that is applied to the element after the `border-bottom-left-radius` CSS property, the value of this property is then reset to its initial value by the [shorthand property](/en-US/docs/Web/CSS/Shorthand_properties). ## Syntax ```css /* the corner is a circle */ /* border-bottom-left-radius: radius */ border-bottom-left-radius: 3px; /* Percentage values */ /* circle if box is a square or ellipse if box is a rectangle */ border-bottom-left-radius: 20%; /* same as above: 20% of horizontal(width) and vertical(height) */ border-bottom-left-radius: 20% 20%; /* 20% of horizontal(width) and 10% of vertical(height) */ border-bottom-left-radius: 20% 10%; /* the corner is an ellipse */ /* border-bottom-left-radius: horizontal vertical */ border-bottom-left-radius: 0.5em 1em; /* Global values */ border-bottom-left-radius: inherit; border-bottom-left-radius: initial; border-bottom-left-radius: revert; border-bottom-left-radius: revert-layer; border-bottom-left-radius: unset; ``` With one value: - the value is a {{cssxref("&lt;length&gt;")}} or a {{cssxref("&lt;percentage&gt;")}} denoting the radius of the circle to use for the border in that corner. With two values: - the first value is a {{cssxref("&lt;length&gt;")}} or a {{cssxref("&lt;percentage&gt;")}} denoting the horizontal semi-major axis of the ellipse to use for the border in that corner. - the second value is a {{cssxref("&lt;length&gt;")}} or a {{cssxref("&lt;percentage&gt;")}} denoting the vertical semi-major axis of the ellipse to use for the border in that corner. ### Values - `<length-percentage>` - : Denotes the size of the circle radius or the semi-major and semi-minor axes of the ellipse. As absolute length it can be expressed in any unit allowed by the CSS {{cssxref("&lt;length&gt;")}} data type. Percentages for the horizontal axis refer to the width of the box, percentages for the vertical axis refer to the height of the box. Negative values are invalid. ## Formal definition {{CSSInfo}} ## Formal syntax {{csssyntax}} ## Examples ### Arc of a circle A single `<length>` value produces an arc of a circle. ```html hidden <div></div> ``` ```css div { border-bottom-left-radius: 40px; background-color: lightgreen; border: solid 1px black; width: 100px; height: 100px; } ``` {{EmbedLiveSample("Arc_of_a_circle")}} ### Arc of an ellipse Two different `<length>` values produce an arc of an ellipse. ```html hidden <div></div> ``` ```css div { border-bottom-left-radius: 40px 20px; background-color: lightgreen; border: solid 1px black; width: 100px; height: 100px; } ``` {{EmbedLiveSample("Arc_of_an_ellipse")}} ### Square element with percentage radius A square element with a single `<percentage>` value produces an arc of a circle. ```html hidden <div></div> ``` ```css div { border-bottom-left-radius: 40%; background-color: lightgreen; border: solid 1px black; width: 100px; height: 100px; } ``` {{EmbedLiveSample("Square_element_with_percentage_radius")}} ### Non-square element with percentage radius A non-square element with a single `<percentage>` value produces an arc of an ellipse. ```html hidden <div></div> ``` ```css div { border-bottom-left-radius: 40%; background-color: lightgreen; border: solid 1px black; width: 200px; height: 100px; } ``` {{EmbedLiveSample("Non-square_element_with_percentage_radius")}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref("border-radius")}} shorthand property - {{cssxref("border-top-right-radius")}}, {{cssxref("border-bottom-right-radius")}}, and {{cssxref("border-top-left-radius")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/filter-function/index.md
--- title: <filter-function> slug: Web/CSS/filter-function page-type: css-type browser-compat: css.types.filter-function --- {{CSSRef}} The **`<filter-function>`** [CSS](/en-US/docs/Web/CSS) [data type](/en-US/docs/Web/CSS/CSS_Types) represents a graphical effect that can change the appearance of an input image. It is used in the {{cssxref("filter")}} and {{cssxref("backdrop-filter")}} properties. ## Syntax The `<filter-function>` data type is specified using one of the filter functions listed below. Each function requires an argument which, if invalid, results in no filter being applied. - {{cssxref("filter-function/blur", "blur()")}} - : Blurs the image. - {{cssxref("filter-function/brightness", "brightness()")}} - : Makes the image brighter or darker. - {{cssxref("filter-function/contrast", "contrast()")}} - : Increases or decreases the image's contrast. - {{cssxref("filter-function/drop-shadow", "drop-shadow()")}} - : Applies a drop shadow behind the image. - {{cssxref("filter-function/grayscale", "grayscale()")}} - : Converts the image to grayscale. - {{cssxref("filter-function/hue-rotate", "hue-rotate()")}} - : Changes the overall hue of the image. - {{cssxref("filter-function/invert", "invert()")}} - : Inverts the colors of the image. - {{cssxref("filter-function/opacity", "opacity()")}} - : Makes the image transparent. - {{cssxref("filter-function/saturate", "saturate()")}} - : Super-saturates or desaturates the input image. - {{cssxref("filter-function/sepia", "sepia()")}} - : Converts the image to sepia. ## Formal syntax {{csssyntax}} ## Examples ### Filter function comparison This example provides a simple graphic, along with a select menu to allow you to choose between the different types of filter function, and a slider to allow you to vary the values used inside the filter function. Updating the controls updates the filter effect in real time, allowing you to investigate the effects of different filters. ```css div { width: 300px; height: 300px; background: url(firefox.png) no-repeat center; filter: <filter-function>(<value>); } ``` Where the `<filter-function>` is the filter you select from the drop down and the `<value>` is the values you set with the slider: ' {{EmbedGHLiveSample("css-examples/types/filterfunctions.html", '100%', '500')}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - Properties that use this data type: {{cssxref("filter")}} and {{cssxref("backdrop-filter")}}
0
data/mdn-content/files/en-us/web/css/filter-function
data/mdn-content/files/en-us/web/css/filter-function/drop-shadow/index.md
--- title: drop-shadow() slug: Web/CSS/filter-function/drop-shadow page-type: css-function browser-compat: css.types.filter-function.drop-shadow --- {{CSSRef}} The **`drop-shadow()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) applies a drop shadow effect to the input image. Its result is a {{cssxref("&lt;filter-function&gt;")}}. {{EmbedInteractiveExample("pages/css/function-drop-shadow.html")}} A drop shadow is effectively a blurred, offset version of the input image's alpha mask, drawn in a specific color and composited below the image. > **Note:** This function is somewhat similar to the {{Cssxref("box-shadow")}} property. The `box-shadow` property creates a rectangular shadow behind an element's _entire box_, while the `drop-shadow()` filter function creates a shadow that conforms to the shape (alpha channel) of the _image itself_. ## Syntax ```css /* Two length values */ /* drop-shadow( <length> <length> ) */ drop-shadow(5px 5px) /* Three length values */ /* drop-shadow( <length> <length> <length> ) */ drop-shadow(5px 5px 15px) /* Two length values and a color */ /* drop-shadow( <length> <length> <color> ) */ drop-shadow(5px 5px red) /* Three length values and a color */ /* drop-shadow( <length> <length> <length> <color> ) */ drop-shadow(5px 5px 15px red) /* The order of color and length values can be changed */ /* drop-shadow( <color> <length> <length> <length> ) */ drop-shadow(#e23 0.5rem 0.5rem 1rem) ``` The `drop-shadow()` function accepts a parameter of type `<shadow>` (defined in the {{cssxref("box-shadow")}} property), with the exception that the `inset` keyword and `spread` parameters are not allowed. ### Parameters - `<color>` {{optional_inline}} - : Specifies the color for the shadow. If not specified, the value of the {{cssxref("color")}} property defined in the parent element is used. - `<length>` - : Specifies the offset length of the shadow. This parameter accepts two or three values. If two values are specified, they are interpreted as `<offset-x>` (horizontal offset) and `<offset-y>` (vertical offset) values. Negative `<offset-x>` value places the shadow to the left of the element. Negative `<offset-y>` value places the shadow above the element. If not specified, the value of `0` is used for the missing length. If a third value is specified, it is interpreted as `<standard-deviation>`, which is the value of the standard deviation to the [Gaussian blur](https://en.wikipedia.org/wiki/Gaussian_blur) function. A larger `<standard-deviation>` value creates a larger and more blurred shadow. Negative values for `<standard-deviation>` are not allowed. ## Formal syntax {{CSSSyntax}} ## Examples ### Setting a drop shadow ```html <div>drop-shadow(16px 16px)</div> <div>drop-shadow(16px 16px red)</div> <div>drop-shadow(red 1rem 1rem 10px)</div> <div>drop-shadow(-16px -16px red)</div> ``` ```css div { display: inline-block; margin: 0 0.5rem 2rem 1rem; padding: 0.5rem; height: 100px; width: 190px; vertical-align: top; background-color: #222; color: lime; } div:nth-child(1) { filter: drop-shadow(16px 16px); } div:nth-child(2) { filter: drop-shadow(16px 16px red); } div:nth-child(3) { filter: drop-shadow(red 1rem 1rem 10px); } div:nth-child(4) { filter: drop-shadow(-16px -6px red); } ``` {{EmbedLiveSample("Setting a drop shadow", "100%", "300px")}} In the absence of a `<color>` value in the `drop-shadow()` function in the first box, the shadow uses the value of the `color` property from the element (`lime`). The second and third shadows illustrate that the length and color values can be specified in any order. The third shadow shows the blurring effect when a third `<length>` value is specified. The fourth shadow uses negative offsets which shifts shadow to the left and top. ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also The other {{cssxref("&lt;filter-function&gt;")}} functions available to be used in values of the {{cssxref("filter")}} and {{cssxref("backdrop-filter")}} properties include: - {{cssxref("filter-function/blur", "blur()")}} - {{cssxref("filter-function/brightness", "brightness()")}} - {{cssxref("filter-function/contrast", "contrast()")}} - {{cssxref("filter-function/grayscale", "grayscale()")}} - {{cssxref("filter-function/hue-rotate", "hue-rotate()")}} - {{cssxref("filter-function/invert", "invert()")}} - {{cssxref("filter-function/opacity", "opacity()")}} - {{cssxref("filter-function/saturate", "saturate()")}} - {{cssxref("filter-function/sepia", "sepia()")}} - {{cssxref("box-shadow")}} property - {{cssxref("text-shadow")}} property
0
data/mdn-content/files/en-us/web/css/filter-function
data/mdn-content/files/en-us/web/css/filter-function/opacity/index.md
--- title: opacity() slug: Web/CSS/filter-function/opacity page-type: css-function browser-compat: css.types.filter-function.opacity --- {{CSSRef}} The **`opacity()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) applies transparency to the samples in the input image. Its result is a {{cssxref("&lt;filter-function&gt;")}}. {{EmbedInteractiveExample("pages/css/function-opacity.html")}} > **Note:** This function is similar to the more established {{Cssxref("opacity")}} property. The difference is that with filters, some browsers provide hardware acceleration for better performance. ## Syntax ```css opacity(amount) ``` ### Parameters - `amount` - : The amount of the conversion, specified as a {{cssxref("&lt;number&gt;")}} or a {{cssxref("&lt;percentage&gt;")}}. A value of `0%` is completely transparent, while a value of `100%` leaves the input unchanged. Values between `0%` and `100%` are linear multipliers on the effect. The initial value for {{Glossary("interpolation")}} is `1`. ## Examples ### Examples of correct values for opacity() ```css opacity(0%) /* Completely transparent */ opacity(50%) /* 50% transparent */ opacity(1) /* No effect */ ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - The other {{cssxref("&lt;filter-function&gt;")}} functions available to be used in values of the {{cssxref("filter")}} and {{cssxref("backdrop-filter")}} properties include: - {{cssxref("filter-function/blur", "blur()")}} - {{cssxref("filter-function/brightness", "brightness()")}} - {{cssxref("filter-function/contrast", "contrast()")}} - {{cssxref("filter-function/drop-shadow", "drop-shadow()")}} - {{cssxref("filter-function/grayscale", "grayscale()")}} - {{cssxref("filter-function/hue-rotate", "hue-rotate()")}} - {{cssxref("filter-function/invert", "invert()")}} - {{cssxref("filter-function/saturate", "saturate()")}} - {{cssxref("filter-function/sepia", "sepia()")}} - The CSS {{cssxref("opacity")}} property
0
data/mdn-content/files/en-us/web/css/filter-function
data/mdn-content/files/en-us/web/css/filter-function/grayscale/index.md
--- title: grayscale() slug: Web/CSS/filter-function/grayscale page-type: css-function browser-compat: css.types.filter-function.grayscale --- {{CSSRef}} The **`grayscale()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) converts the input image to grayscale. Its result is a {{cssxref("&lt;filter-function&gt;")}}. {{EmbedInteractiveExample("pages/css/function-grayscale.html")}} ## Syntax ```css grayscale(amount) ``` ### Parameters - `amount` - : Amount of the input image that is converted to grayscale. It is specified as a {{cssxref("&lt;number&gt;")}} or a {{cssxref("&lt;percentage&gt;")}}. A value of `100%` changes the input completely to grayscale, while a value of `0%` leaves the input unchanged. Values between `0%` and `100%` have linear multipliers on the effect. If the `grayscale()` filter is present with no parameter, the default value is `1`. The initial value used for {{Glossary("interpolation")}} is `0`. ## Examples ### Examples of correct values for grayscale() ```css grayscale(0) /* No effect */ grayscale(.7) /* 70% grayscale */ grayscale(100%) /* Completely grayscale */ ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also The other {{cssxref("&lt;filter-function&gt;")}} functions available to be used in values of the {{cssxref("filter")}} and {{cssxref("backdrop-filter")}} properties include: - {{cssxref("filter-function/blur", "blur()")}} - {{cssxref("filter-function/brightness", "brightness()")}} - {{cssxref("filter-function/contrast", "contrast()")}} - {{cssxref("filter-function/drop-shadow", "drop-shadow()")}} - {{cssxref("filter-function/hue-rotate", "hue-rotate()")}} - {{cssxref("filter-function/invert", "invert()")}} - {{cssxref("filter-function/opacity", "opacity()")}} - {{cssxref("filter-function/saturate", "saturate()")}} - {{cssxref("filter-function/sepia", "sepia()")}}
0
data/mdn-content/files/en-us/web/css/filter-function
data/mdn-content/files/en-us/web/css/filter-function/brightness/index.md
--- title: brightness() slug: Web/CSS/filter-function/brightness page-type: css-function browser-compat: css.types.filter-function.brightness --- {{CSSRef}} The **`brightness()`** [CSS](/en-US/docs/Web/CSS) {{cssxref("&lt;filter-function&gt;")}} applies a linear multiplier value on an element or an input image, making the image appear brighter or darker. {{EmbedInteractiveExample("pages/css/function-brightness.html")}} ## Syntax ```css brightness(amount) ``` ### Values - `amount` - : Brightness specified as a {{cssxref("&lt;number&gt;")}} or a {{cssxref("&lt;percentage&gt;")}}. A value less than `100%` darkens the input image or element, while a value over `100%` brightens it. A value of `0%` creates a completely black image or element, while a value of `100%` leaves the input unchanged. Other values between `0%` to `100%` have a linear multiplier effect. Values greater than `100%` are allowed, providing brighter results. The initial value for {{Glossary("interpolation")}} is `1`. Negative values are not allowed. The default value, when nothing is specified, is `1`. The following are pairs of equivalent values: ```css brightness(0) /* Brightness is reduced to zero, so input turns black */ brightness(0%) brightness(0.4) /* Brightness of input is reduced to 40%, so input is 60% darker */ brightness(40%) brightness(1) /* Brightness of input is not changed */ brightness(100%) brightness(2) /* Brightness of input is doubled */ brightness(200%) ``` ### Formal syntax {{csssyntax}} ## Examples ### Applying brightness using the backdrop-filter property This example shows how to apply the `brightness()` filter to a paragraph via the [`backdrop-filter`](/en-US/docs/Web/CSS/backdrop-filter) CSS property. #### CSS ```css .container { background: url(image.jpg) no-repeat right / contain #d4d5b2; } p { backdrop-filter: brightness(150%); text-shadow: 2px 2px #ffffff; } ``` ```css hidden .container { padding: 5rem 3rem 1rem; width: 30rem; } p { padding: 0.5rem; color: #000000; font-size: 2rem; font-family: sans-serif; } ``` ```html hidden <div class="container" style="background-image: url(be_fierce.jpg);"> <p> Text on images can be illegible and inaccessible even with a drop shadow. </p> </div> ``` #### Result {{EmbedLiveSample('Applying_brightness_using_the_backdrop_filter_property', '100%', '280')}} In this example, the colors in the area behind the `<p>` element shift linearly. If the `backdrop-filter` property was set to `brightness(0%)`, the `<div>` area with the `<p>` element would have been black and hidden the image behind. At `brightness(100%)`, the `<div>` area color would be the same as the input `#d4d5b2`, and the image behind would be completely transparent. With the brightness set to `150%` as in this example, the colors in the image behind are getting hidden by the brightness of the `<div>` element.` ### Applying brightness using the filter property In this example, a `brightness()` filter is applied to the entire element, including content, border, and background image via the [`filter`](/en-US/docs/Web/CSS/filter) CSS property. The result shows three variations of different brightness values. ```css p:first-of-type { filter: brightness(50%); } p:last-of-type { filter: brightness(200%); } ``` ```css hidden p { text-shadow: 2px 2px blue; background-color: magenta; color: palegoldenrod; border: 1em solid rebeccapurple; box-shadow: inset -5px -5px red, 5px 5px yellow; padding: 0.25rem; font-size: 1.25rem; font-family: sans-serif; width: 85vw; } ``` ```html hidden <p>This paragraph has reduced brightness.</p> <p>This paragraph has normal brightness.</p> <p>This paragraph has increased brightness.</p> ``` {{EmbedLiveSample('Applying_brightness_using_the_filter_property','100%','280')}} ### Applying brightness using the url() SVG brightness filter The SVG {{SVGElement("filter")}} element is used to define custom filter effects that can then be referenced by [`id`](/en-US/docs/Web/HTML/Global_attributes#id). The `<filter>` element's {{SVGElement("feComponentTransfer")}} primitive enables pixel-level color remapping. In this example, to create a filter that darkens the content on which it is applied by 25% (i.e., 75% of the original brightness), the `slope` attribute is set to `0.75`. We can then reference the filter by `id`. Given the following: ```css hidden .filter { filter: brightness(0.75); } svg { position: absolute; } ``` ```html <svg role="none"> <filter id="darken25" color-interpolation-filters="sRGB"> <feComponentTransfer> <feFuncR type="linear" slope="0.75" /> <feFuncG type="linear" slope="0.75" /> <feFuncB type="linear" slope="0.75" /> </feComponentTransfer> </filter> </svg> ``` The following declarations produce similar effects: ```css filter: brightness(75%); filter: url(#darken25); /* with embedded SVG */ filter: url(folder/fileName.svg#darken25); /* external svg filter definition */ ``` In the images below, the first one has a `brightness()` filter function applied, the second one has a similar SVG brightness function applied, and the third is the original image for comparison. ```html hidden <table cellpadding="5"> <thead> <tr> <th>Live example</th> <th>SVG Equivalent</th> <th>Original image</th> </tr> </thead> <tbody> <tr> <td><img class="filter" src="flag.jpg" alt="darkened pride flag" /></td> <td> <img style="filter: url(#darken25)" src="flag.jpg" alt="darkened pride flag" /> </td> <td> <img src="flag.jpg" alt="Pride flag" /> </td> </tr> </tbody> </table> ``` {{EmbedLiveSample('blur','100%','280')}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS filter effects](/en-US/docs/Web/CSS/CSS_filter_effects) module - The other {{cssxref("&lt;filter-function&gt;")}} functions available to be used in values of the {{cssxref("filter")}} and {{cssxref("backdrop-filter")}} properties include: - {{cssxref("filter-function/blur", "blur()")}} - {{cssxref("filter-function/contrast", "contrast()")}} - {{cssxref("filter-function/drop-shadow", "drop-shadow()")}} - {{cssxref("filter-function/grayscale", "grayscale()")}} - {{cssxref("filter-function/hue-rotate", "hue-rotate()")}} - {{cssxref("filter-function/invert", "invert()")}} - {{cssxref("filter-function/opacity", "opacity()")}} - {{cssxref("filter-function/saturate", "saturate()")}} - {{cssxref("filter-function/sepia", "sepia()")}}
0
data/mdn-content/files/en-us/web/css/filter-function
data/mdn-content/files/en-us/web/css/filter-function/hue-rotate/index.md
--- title: hue-rotate() slug: Web/CSS/filter-function/hue-rotate page-type: css-function browser-compat: css.types.filter-function.hue-rotate --- {{CSSRef}} The **`hue-rotate()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) rotates the [hue](https://en.wikipedia.org/wiki/Hue) of an element and its contents. Its result is a {{cssxref("&lt;filter-function&gt;")}}. {{EmbedInteractiveExample("pages/css/function-hue-rotate.html")}} ## Syntax The `hue-rotate()` function applies a color rotation to the elements on which it is applied. ```css hue-rotate(angle) ``` ### Values - `angle` - : The relative change in hue of the input sample, specified as an {{cssxref("&lt;angle&gt;")}}. A value of `0deg` leaves the input unchanged. A positive hue rotation increases the hue value, while a negative rotation decreases the hue value. The initial value for {{Glossary("interpolation")}} is `0`. There is no minimum or maximum value. The effect of values above `360deg` are, given `hue-rotate(Ndeg)`, evaluates to `N` modulo 360. The `<angle>` CSS data type represents an angle value expressed in degrees, gradians, radians, or turns. The following are equivalent: ```css hue-rotate(-180deg) hue-rotate(540deg) hue-rotate(200grad) hue-rotate(3.14159rad) hue-rotate(0.5turn) ``` ### Formal syntax {{csssyntax}} ## Examples ### With the backdrop-filter property This example applies a `hue-rotate()` filter via the `backdrop-filter` CSS property to the paragraph, color shifting to the area behind the `<p>`. ```css .container { background: url(image.jpg) no-repeat left / contain #011296; } p { backdrop-filter: hue-rotate(240deg); text-shadow: 2px 2px #011296; } ``` ```css hidden .container { padding: 3rem; width: 30rem; } p { padding: 0.5rem; color: #ffffff; font-size: 2rem; font-family: sans-serif; } ``` ```html hidden <div class="container" style="background-image: url(listen_to_black_women.jpg);"> <p> Text on images can be illegible and inaccessible even with a drop shadow. </p> </div> ``` {{EmbedLiveSample('With_the_backdrop-filter_property','100%','280')}} ### With the filter property This example applies a `hue-rotate()` filter via the `filter` CSS property adding the color shift to the entire element, including content, border, and background image. ```css p { filter: hue-rotate(-60deg); text-shadow: 2px 2px blue; background-color: magenta; color: goldenrod; border: 1em solid rebeccapurple; box-shadow: inset -5px -5px red, 5px 5px yellow; } ``` ```css hidden p { padding: 0.5rem; font-size: 2rem; font-family: sans-serif; width: 85vw; } ``` ```html hidden <p>The person who wrote this example is not a designer, fortunately.</p> ``` {{EmbedLiveSample('With_the_filter_property','100%','220')}} ### With url() and the SVG hue-rotate filter The SVG {{SVGElement("filter")}} element is used to define custom filter effects that can then be referenced by [`id`](/en-US/docs/Web/HTML/Global_attributes#id). The `<filter>`'s {{SVGElement("feColorMatrix")}} primitive `hueRotate` type provides the same effect. Given the following: ```svg <filter id="filterID"> <feColorMatrix type="hueRotate" values="90" /> </filter> ``` These values produce the same results: ```css filter: hue-rotate(90deg); /* 90deg rotation */ filter: url(#filterID); /* with embedded SVG */ filter: url(folder/fileName.svg#filterID); /* external svg filter definition */ ``` This example shows three images: the image with a `hue-rotate()` filter function applied, the image with an equivalent `url()` filter applied, and the original images for comparison: ```html hidden <table cellpadding="5"> <thead> <tr> <th><code>hue-rotate()</code></th> <th><code>url()</code></th> <th>Original image</th> </tr> </thead> <tbody> <tr> <td> <img style="filter: hue-rotate(90deg)" src="flag.jpg" alt="Pride flag with rotated colors" /> </td> <td> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 220 220" color-interpolation-filters="sRGB" height="220" width="220"> <filter id="hue-rotate"> <feColorMatrix type="hueRotate" values="90" /> </filter> <image xlink:href="flag.jpg" filter="url(#hue-rotate)" width="220" height="220" /> </svg> </td> <td><img src="flag.jpg" alt="Pride flag" /></td> </tr> </tbody> </table> ``` {{EmbedLiveSample('With_url()_and_the_SVG_hue-rotate_filter','100%','280')}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS filter effects](/en-US/docs/Web/CSS/CSS_filter_effects) module - The other {{cssxref("&lt;filter-function&gt;")}} functions available to be used in values of the {{cssxref("filter")}} and {{cssxref("backdrop-filter")}} properties include: - {{cssxref("filter-function/blur", "blur()")}} - {{cssxref("filter-function/brightness", "brightness()")}} - {{cssxref("filter-function/contrast", "contrast()")}} - {{cssxref("filter-function/drop-shadow", "drop-shadow()")}} - {{cssxref("filter-function/grayscale", "grayscale()")}} - {{cssxref("filter-function/invert", "invert()")}} - {{cssxref("filter-function/opacity", "opacity()")}} - {{cssxref("filter-function/saturate", "saturate()")}} - {{cssxref("filter-function/sepia", "sepia()")}}
0
data/mdn-content/files/en-us/web/css/filter-function
data/mdn-content/files/en-us/web/css/filter-function/sepia/index.md
--- title: sepia() slug: Web/CSS/filter-function/sepia page-type: css-function browser-compat: css.types.filter-function.sepia --- {{CSSRef}} The **`sepia()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) converts the input image to sepia, giving it a warmer, more yellow/brown appearance. Its result is a {{cssxref("&lt;filter-function&gt;")}}. {{EmbedInteractiveExample("pages/css/function-sepia.html")}} ## Syntax ```css sepia(amount) ``` ### Parameters - `amount` - : The amount of the conversion, specified as a {{cssxref("&lt;number&gt;")}} or a {{cssxref("&lt;percentage&gt;")}}. A value of `100%` is completely sepia, while a value of `0%` leaves the input unchanged. Values between `0%` and `100%` are linear multipliers on the effect. The initial value for {{Glossary("interpolation")}} is `0`. ## Examples ### Examples of correct values for sepia() ```css sepia(0) /* No effect */ sepia(.65) /* 65% sepia */ sepia(100%) /* Completely sepia */ ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also The other {{cssxref("&lt;filter-function&gt;")}} functions available to be used in values of the {{cssxref("filter")}} and {{cssxref("backdrop-filter")}} properties include: - {{cssxref("filter-function/blur", "blur()")}} - {{cssxref("filter-function/brightness", "brightness()")}} - {{cssxref("filter-function/contrast", "contrast()")}} - {{cssxref("filter-function/drop-shadow", "drop-shadow()")}} - {{cssxref("filter-function/grayscale", "grayscale()")}} - {{cssxref("filter-function/hue-rotate", "hue-rotate()")}} - {{cssxref("filter-function/invert", "invert()")}} - {{cssxref("filter-function/opacity", "opacity()")}} - {{cssxref("filter-function/saturate", "saturate()")}}
0
data/mdn-content/files/en-us/web/css/filter-function
data/mdn-content/files/en-us/web/css/filter-function/saturate/index.md
--- title: saturate() slug: Web/CSS/filter-function/saturate page-type: css-function browser-compat: css.types.filter-function.saturate --- {{CSSRef}} The **`saturate()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) super-saturates or desaturates the input image. Its result is a {{cssxref("&lt;filter-function&gt;")}}. {{EmbedInteractiveExample("pages/css/function-saturate.html")}} ## Syntax ```css saturate(amount) ``` ### Parameters - `amount` - : The amount of the conversion, specified as a {{cssxref("&lt;number&gt;")}} or a {{cssxref("&lt;percentage&gt;")}}. A value under `100%` desaturates the image, while a value over `100%` super-saturates it. A value of `0%` is completely unsaturated, while a value of `100%` leaves the input unchanged. The initial value for {{Glossary("interpolation")}} is `1`. ## Examples ### Examples of correct values for saturate() ```css saturate(0) /* Completely unsaturated */ saturate(.4) /* 40% saturated */ saturate(100%) /* No effect */ saturate(200%) /* Double saturation */ ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also The other {{cssxref("&lt;filter-function&gt;")}} functions available to be used in values of the {{cssxref("filter")}} and {{cssxref("backdrop-filter")}} properties include: - {{cssxref("filter-function/blur", "blur()")}} - {{cssxref("filter-function/brightness", "brightness()")}} - {{cssxref("filter-function/contrast", "contrast()")}} - {{cssxref("filter-function/drop-shadow", "drop-shadow()")}} - {{cssxref("filter-function/grayscale", "grayscale()")}} - {{cssxref("filter-function/hue-rotate", "hue-rotate()")}} - {{cssxref("filter-function/invert", "invert()")}} - {{cssxref("filter-function/opacity", "opacity()")}} - {{cssxref("filter-function/sepia", "sepia()")}}
0
data/mdn-content/files/en-us/web/css/filter-function
data/mdn-content/files/en-us/web/css/filter-function/contrast/index.md
--- title: contrast() slug: Web/CSS/filter-function/contrast page-type: css-function browser-compat: css.types.filter-function.contrast --- {{CSSRef}} The **`contrast()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) adjusts the contrast of the input image. Its result is a {{cssxref("&lt;filter-function&gt;")}}. {{EmbedInteractiveExample("pages/css/function-contrast.html")}} ## Syntax ```css contrast(amount) ``` ### Values - `amount` - : The contrast of the result, specified as a {{cssxref("&lt;number&gt;")}} or a {{cssxref("&lt;percentage&gt;")}}. A value under `100%` decreases the contrast, while a value over `100%` increases it. A value of `0` or `0%` will create an image that is completely gray, while a value of `1` or `100%` leaves the input unchanged. Negative values are not allowed. The initial value for {{Glossary("interpolation")}} is `1`. The following are pairs of equivalent values: ```css contrast(0) /* Completely gray */ contrast(0%) contrast(0.65) /* 65% contrast */ contrast(65%) contrast(1) /* No effect */ contrast(100%) contrast(2) /* Double contrast */ contrast(200%) ``` ### Formal syntax {{csssyntax}} ## Examples ### With the backdrop-filter property This example applies a `contrast()` filter via the {{cssxref("backdrop-filter")}} CSS property to the paragraph and monospaced text, color shifting to the area behind the `<p>` and `<code>`. ```css .container { background: url(image.jpg) no-repeat center / contain #339; } p { backdrop-filter: contrast(0.5); } code { backdrop-filter: contrast(0.15); } ``` ```css hidden .container { padding: 3rem; width: 30rem; } p { padding: 0.5rem; color: #ffffff; font-family: sans-serif; } ``` ```html hidden <div class="container" style="background-image: url(unity_for_the_people.jpg);"> <p> Always ensure there is enough contrast between text and all background colors. If you think your text may land on top of a background image, include a <code>backdrop-filter</code>. Reducing the contrast of background colors with the <code>contrast()</code> filter may improve legibility but does not guarantee accessibility. </p> </div> ``` {{EmbedLiveSample('With_the_backdrop-filter_property','100%','260')}} ### With the filter property This example applies a `contrast()` filter via the {{cssxref("filter")}} CSS property, changing contrast by shifting colors of the entire element, including content, border, background, and shadows. ```css p:first-of-type { filter: contrast(30%); } p:last-of-type { filter: contrast(300%); } ``` ```css hidden p { text-shadow: 2px 2px blue; background-color: magenta; color: palegoldenrod; border: 1em solid rebeccapurple; box-shadow: inset -5px -5px red, 5px 5px yellow; padding: 0.25rem; font-size: 1.25rem; font-family: sans-serif; width: 85vw; } ``` ```html hidden <p>This paragraph has reduced contrast.</p> <p>This paragraph has normal contrast.</p> <p>This paragraph has increased contrast.</p> ``` {{EmbedLiveSample('With_the_filter_property','100%','320')}} ### With url() and the SVG contrast filter The SVG {{SVGElement("filter")}} element is used to define custom filter effects that can then be referenced by [`id`](/en-US/docs/Web/HTML/Global_attributes#id). The `<filter>`'s {{SVGElement("feComponentTransfer")}} primitive enables pixel-level color remapping. Given the following: ```svg <filter id="contrast"> <feComponentTransfer> <feFuncR type="linear" slope="2" intercept="-0.5"/> <feFuncG type="linear" slope="2" intercept="-0.5"/> <feFuncB type="linear" slope="2" intercept="-0.5"/> </feComponentTransfer> </filter> ``` ```css hidden .svgFilterLive { filter: url(#contrast2); } ``` These values produce the same results: ```css filter: contrast(200%); filter: url(#contrast); /* with embedded SVG */ filter: url(folder/fileName.svg#contrast); /* external svg filter definition */ ``` This example shows three images: the image with a `contrast()` filter function applied, the image with an equivalent `url()` filter applied, and the original images for comparison: ```html hidden <table cellpadding="5"> <thead> <tr> <th><code>contrast()</code></th> <th><code>url()</code></th> <th>Original image</th> </tr> </thead> <tbody> <tr> <td> <img style="filter: contrast(200%)" src="flag.jpg" alt="Pride flag" /> </td> <td> <img class="svgFilterLive" src="flag.jpg" alt="Pride flag" /> <svg xmlns="http://www.w3.org/2000/svg" id="svg" viewBox="0 0 240 151" height="0" width="0" style="overflow: visible" color-interpolation-filters="sRGB"> <filter id="contrast2"> <feComponentTransfer> <feFuncR type="linear" slope="2" intercept="-0.5" /> <feFuncG type="linear" slope="2" intercept="-0.5" /> <feFuncB type="linear" slope="2" intercept="-0.5" /> </feComponentTransfer> </filter> </svg> </td> <td> <img src="flag.jpg" alt="Pride flag" /> </td> </tr> </tbody> </table> ``` {{EmbedLiveSample('With_url()_and_the_SVG_contrast_filter','100%','280')}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS filter effects](/en-US/docs/Web/CSS/CSS_filter_effects) module - The other {{cssxref("&lt;filter-function&gt;")}} functions available to be used in values of the {{cssxref("filter")}} and {{cssxref("backdrop-filter")}} properties include: - {{cssxref("filter-function/blur", "blur()")}} - {{cssxref("filter-function/brightness", "brightness()")}} - {{cssxref("filter-function/drop-shadow", "drop-shadow()")}} - {{cssxref("filter-function/grayscale", "grayscale()")}} - {{cssxref("filter-function/hue-rotate", "hue-rotate()")}} - {{cssxref("filter-function/invert", "invert()")}} - {{cssxref("filter-function/opacity", "opacity()")}} - {{cssxref("filter-function/saturate", "saturate()")}} - {{cssxref("filter-function/sepia", "sepia()")}}
0
data/mdn-content/files/en-us/web/css/filter-function
data/mdn-content/files/en-us/web/css/filter-function/blur/index.md
--- title: blur() slug: Web/CSS/filter-function/blur page-type: css-function browser-compat: css.types.filter-function.blur --- {{CSSRef}} The **`blur()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) applies a [Gaussian blur](https://en.wikipedia.org/wiki/Gaussian_blur) to the input image. Its result is a {{cssxref("&lt;filter-function&gt;")}}. {{EmbedInteractiveExample("pages/css/function-blur.html")}} ## Syntax The `blur()` function applies a Gaussian blur to the elements on which it is applied. ```css blur(radius) ``` ### Parameters - `radius` - : The radius of the blur, specified as a {{cssxref("&lt;length&gt;")}}. It defines the value of the standard deviation to the Gaussian function, i.e., how many pixels on the screen blend into each other; thus, a larger value will create more blur. A value of `0` leaves the input unchanged. The initial value for {{Glossary("interpolation")}} is `0`. Percentage values are invalid. ### Setting a blur with pixels and with rem ```css blur(0) /* No effect */ blur(8px) /* Blur with 8px radius */ blur(1.17rem) /* Blur with 1.17rem radius */ ``` ## SVG filter The SVG {{SVGElement("feGaussianBlur")}} filter element can also be used to blur content. The filter's {{SVGAttr("stdDeviation")}} attribute accepts up to two values enabling creating more complex blur values. To create an equivalent blur, we include one value for `stdDeviation`. This SVG effect can then be referenced by ID: ```html <svg role="none"> <filter id="blur11"> <feGaussianBlur stdDeviation="1.1" edgeMode="duplicate" /> </filter> </svg> ``` The following declarations produce the same effect: ```css filter: blur(1.1px); filter: url(#blur11); /* with embedded SVG */ filter: url(folder/fileName.svg#blur11); /* external svg filter definition */ ``` ## Examples This example shows three images: the image with a `blur()` filter function applied, the image with the equivalent SVG blur function applied, and the original images for comparison: ```css .filter { filter: blur(3.5px); } ``` ```html <svg role="img" aria-label="Flag"> <filter id="blur"> <feGaussianBlur stdDeviation="3.5" edgeMode="duplicate" /> </filter> <image href="flag.jpg" xlink:href="flag.jpg" filter="url(#blur)" /> </svg> ``` ```css hidden svg:not([height]) { display: none; } ``` ```html hidden <table cellpadding="5"> <thead> <tr> <th>Live example</th> <th>SVG Equivalent</th> <th>Original image</th> </tr> </thead> <tbody> <tr> <td> <img class="filter" src="flag.jpg" alt="Pride flag" /> </td> <td> <svg id="svg" height="220" width="220" style="overflow: visible"> <filter id="svgBlur"> <feGaussianBlur stdDeviation="3.5" /> </filter> <image href="flag.jpg" xlink:href="flag.jpg" filter="url(#svgBlur)" /> </svg> </td> <td> <img src="flag.jpg" alt="Pride flag" /> </td> </tr> </tbody> </table> ``` {{EmbedLiveSample('blur','100%','280')}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS filter effects](/en-US/docs/Web/CSS/CSS_filter_effects) module - The other {{cssxref("&lt;filter-function&gt;")}} functions available to be used in values of the {{cssxref("filter")}} and {{cssxref("backdrop-filter")}} properties include: - {{cssxref("filter-function/brightness", "brightness()")}} - {{cssxref("filter-function/contrast", "contrast()")}} - {{cssxref("filter-function/drop-shadow", "drop-shadow()")}} - {{cssxref("filter-function/grayscale", "grayscale()")}} - {{cssxref("filter-function/hue-rotate", "hue-rotate()")}} - {{cssxref("filter-function/invert", "invert()")}} - {{cssxref("filter-function/opacity", "opacity()")}} - {{cssxref("filter-function/saturate", "saturate()")}} - {{cssxref("filter-function/sepia", "sepia()")}}
0
data/mdn-content/files/en-us/web/css/filter-function
data/mdn-content/files/en-us/web/css/filter-function/invert/index.md
--- title: invert() slug: Web/CSS/filter-function/invert page-type: css-function browser-compat: css.types.filter-function.invert --- {{CSSRef}} The **`invert()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) inverts the color samples in the input image. Its result is a {{cssxref("&lt;filter-function&gt;")}}. {{EmbedInteractiveExample("pages/css/function-invert.html")}} ## Syntax ```css invert(amount) ``` ### Parameters - `amount` - : The amount of the conversion, specified as a {{cssxref("&lt;number&gt;")}} or a {{cssxref("&lt;percentage&gt;")}}. A value of `100%` is completely inverted, while a value of `0%` leaves the input unchanged. Values between `0%` and `100%` are linear multipliers on the effect. The initial value for {{Glossary("interpolation")}} is `0`. ## Examples ### Examples of correct values for invert() ```css invert(0) /* No effect */ invert(.6) /* 60% inversion */ invert(100%) /* Completely inverted */ ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also The other {{cssxref("&lt;filter-function&gt;")}} functions available to be used in values of the {{cssxref("filter")}} and {{cssxref("backdrop-filter")}} properties include: - {{cssxref("filter-function/blur", "blur()")}} - {{cssxref("filter-function/brightness", "brightness()")}} - {{cssxref("filter-function/contrast", "contrast()")}} - {{cssxref("filter-function/drop-shadow", "drop-shadow()")}} - {{cssxref("filter-function/grayscale", "grayscale()")}} - {{cssxref("filter-function/hue-rotate", "hue-rotate()")}} - {{cssxref("filter-function/opacity", "opacity()")}} - {{cssxref("filter-function/saturate", "saturate()")}} - {{cssxref("filter-function/sepia", "sepia()")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/text-shadow/index.md
--- title: text-shadow slug: Web/CSS/text-shadow page-type: css-property browser-compat: css.properties.text-shadow --- {{CSSRef}} The **`text-shadow`** CSS property adds shadows to text. It accepts a comma-separated list of shadows to be applied to the text and any of its [`decorations`](/en-US/docs/Web/CSS/text-decoration). Each shadow is described by some combination of X and Y offsets from the element, blur radius, and color. {{EmbedInteractiveExample("pages/css/text-shadow.html")}} ## Syntax ```css /* offset-x | offset-y | blur-radius | color */ text-shadow: 1px 1px 2px black; /* color | offset-x | offset-y | blur-radius */ text-shadow: #fc0 1px 0 10px; /* offset-x | offset-y | color */ text-shadow: 5px 5px #558abb; /* color | offset-x | offset-y */ text-shadow: white 2px 5px; /* offset-x | offset-y /* Use defaults for color and blur-radius */ text-shadow: 5px 10px; /* Global values */ text-shadow: inherit; text-shadow: initial; text-shadow: revert; text-shadow: revert-layer; text-shadow: unset; ``` This property is specified as a comma-separated list of shadows. Each shadow is specified as two or three `<length>` values, followed optionally by a `<color>` value. The first two `<length>` values are the `<offset-x>` and `<offset-y>` values. The third, optional, `<length>` value is the `<blur-radius>`. The `<color>` value is the shadow's color. When more than one shadow is given, shadows are applied front-to-back, with the first-specified shadow on top. This property applies to both {{cssxref("::first-line")}} and {{cssxref("::first-letter")}} [pseudo-elements](/en-US/docs/Web/CSS/Pseudo-elements). ### Values - {{cssxref("&lt;color&gt;")}} - : Optional. The color of the shadow. It can be specified either before or after the offset values. If unspecified, the color's value is left up to the user agent, so when consistency across browsers is desired you should define it explicitly. - `<offset-x> <offset-y>` - : Required. These {{cssxref("&lt;length&gt;")}} values specify the shadow's distance from the text. `<offset-x>` specifies the horizontal distance; a negative value places the shadow to the left of the text. `<offset-y>` specifies the vertical distance; a negative value places the shadow above the text. If both values are `0`, the shadow is placed directly behind the text, although it may be partly visible due to the effect of `<blur-radius>`. - `<blur-radius>` - : Optional. This is a {{cssxref("&lt;length&gt;")}} value. The higher the value, the bigger the blur; the shadow becomes wider and lighter. If not specified, it defaults to `0`. ## Formal definition {{CSSInfo}} ## Formal syntax {{csssyntax}} ## Examples ### Simple shadow ```css .red-text-shadow { text-shadow: red 0 -2px; } ``` ```html <p class="red-text-shadow"> Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore. </p> ``` {{EmbedLiveSample('Simple_shadow', '660px', '90px')}} ### Multiple shadows ```css .white-text-with-blue-shadow { text-shadow: 1px 1px 2px black, 0 0 1em blue, 0 0 0.2em blue; color: white; font: 1.5em Georgia, serif; } ``` ```html <p class="white-text-with-blue-shadow"> Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore. </p> ``` {{EmbedLiveSample('Multiple_shadows', '660px', '170px')}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - The {{cssxref("&lt;color&gt;")}} data type (for specifying the shadow color) - {{cssxref("box-shadow")}} - {{cssxref("filter-function/drop-shadow", "drop-shadow()")}} - [Applying color to HTML elements using CSS](/en-US/docs/Web/CSS/CSS_colors/Applying_color)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/hue/index.md
--- title: <hue> slug: Web/CSS/hue page-type: css-type browser-compat: - css.types.color.hsl - css.types.color.hwb - css.types.color.lch - css.types.color.oklch spec-urls: https://drafts.csswg.org/css-color/#typedef-hue --- {{CSSRef}} The **`<hue>`** [CSS](/en-US/docs/Web/CSS) [data type](/en-US/docs/Web/CSS/CSS_Types) represents the hue angle of a color. It is used in the color functions that accept hue expressed as a single value, specifically [`hsl()`](/en-US/docs/Web/CSS/color_value/hsl), [`hwb()`](/en-US/docs/Web/CSS/color_value/hwb), [`lch()`](/en-US/docs/Web/CSS/color_value/lch), and [`oklch()`](/en-US/docs/Web/CSS/color_value/oklch) functional notations. ![An sRGB color wheel](color_wheel.svg) The color wheel above shows hues at all angles in the [sRGB](https://en.wikipedia.org/wiki/SRGB) color space. In particular, _red_ is at `0deg`, _yellow_ is at `60deg`, _lime_ is at `120deg`, _cyan_ is at `180deg`, _blue_ is at `240deg`, and _magenta_ is at `300deg`. > **Note:** The angles corresponding to particular hues depend on the color space. For example, the hue angle of sRGB green is `120deg` in the sRGB color space, but `134.39deg` in the CIELAB color space. The following table lists typical colors at various angles in the sRGB (used by {{CSSXref("color_value/hsl", "hsl()")}} and {{CSSXref("color_value/hwb", "hwb()")}}), CIELAB (used by {{CSSXref("color_value/lch", "lch()")}}), and Oklab (used by {{CSSXref("color_value/oklch", "oklch()")}}) color spaces: <table> <colgroup> <col /> <col span="6" width="15%" /> </colgroup> <thead> <tr> <th></th> <th scope="col">0°</th> <th scope="col">60°</th> <th scope="col">120°</th> <th scope="col">180°</th> <th scope="col">240°</th> <th scope="col">300°</th> </tr> </thead> <tbody> <tr> <th scope="row">sRGB</th> <td style="background: hsl(0 100% 50%);" title="hsl(0 100% 50%)"></td> <td style="background: hsl(60 100% 50%);" title="hsl(60 100% 50%)"></td> <td style="background: hsl(120 100% 50%);" title="hsl(120 100% 50%)"></td> <td style="background: hsl(180 100% 50%);" title="hsl(180 100% 50%)"></td> <td style="background: hsl(240 100% 50%);" title="hsl(240 100% 50%)"></td> <td style="background: hsl(300 100% 50%);" title="hsl(300 100% 50%)"></td> </tr> <tr> <th scope="row">CIELAB</th> <td style="background: lch(50% 50% 0);" title="lch(50% 50% 0)"></td> <td style="background: lch(65% 55% 60);" title="lch(65% 55% 60)"></td> <td style="background: lch(90% 65% 120);" title="lch(90% 65% 120)"></td> <td style="background: lch(90% 35% 180);" title="lch(90% 35% 180)"></td> <td style="background: lch(75% 25% 240);" title="lch(75% 25% 240)"></td> <td style="background: lch(40% 70% 300);" title="lch(40% 70% 300)"></td> </tr> <tr> <th scope="row">Oklab</th> <td style="background: oklch(65% 65% 0);" title="oklch(65% 65% 0)"></td> <td style="background: oklch(75% 40% 60);" title="oklch(75% 40% 60)"></td> <td style="background: oklch(90% 50% 120);" title="oklch(90% 50% 120)"></td> <td style="background: oklch(90% 35% 180);" title="oklch(90% 35% 180)"></td> <td style="background: oklch(70% 40% 240);" title="oklch(70% 40% 240)"></td> <td style="background: oklch(55% 70% 300);" title="oklch(55% 70% 300)"></td> </tr> </tbody> </table> ## Syntax A `<hue>` can be either an `<angle>` or a `<number>`. ### Values - {{CSSXref("&lt;angle&gt;")}} - : An angle expressed in degrees, gradians, radians, or turns using the `deg`, `grad`, `rad`, or `turn`, respectively. - `<number>` - : A real number, representing degrees of the hue angle. As an `<angle>` is periodic, `<hue>` is normalized to the range `[0deg, 360deg)`. It implicitly wraps around such that `480deg` is the same as `120deg`, `-120deg` is the same as `240deg`, `-1turn` is the same as `1turn`, and so on. ### Interpolation `<hue>` values are interpolated as {{CSSXref("&lt;angle&gt;")}} values, and the default interpolation algorithm is [`shorter`](/en-US/docs/Web/CSS/hue-interpolation-method#values). In some color-related CSS functions, this can be overridden by the {{CSSXref("&lt;hue-interpolation-method&gt;")}} component. ### Formal syntax {{csssyntax}} ## Examples ### Changing the hue of a color using a slider The following example shows the effect of changing the `hue` value of the [`hsl()`](/en-US/docs/Web/CSS/color_value/hsl) functional notation on a color. #### HTML ```html <input type="range" min="0" max="360" value="0" id="hue-slider" /> <p>Hue: <span id="hue-value">0deg</span></p> <div id="box"></div> ``` #### CSS ```css hidden div { width: 100px; height: 100px; margin: 10px; border: 1px solid black; } p { font-family: sans-serif; } span { font-family: monospace; background: rgb(0 0 0 / 10%); padding: 3px; } #hue-slider { width: 90%; } ``` ```css #box { background-color: hsl(0 100% 50%); } ``` #### JavaScript ```js const hue = document.querySelector("#hue-slider"); const box = document.querySelector("#box"); hue.addEventListener("input", () => { box.style.backgroundColor = `hsl(${hue.value} 100% 50%)`; document.querySelector("#hue-value").textContent = `${hue.value}deg`; }); ``` #### Result {{EmbedLiveSample("changing_the_hue_of_a_color_using_a_slider", "100%", "200")}} ### Approximating red hues in different color spaces The following example shows a similar red color in different color spaces. The values in the `lch()` and `oklch()` functions are rounded for readability. #### HTML ```html <div data-color="hsl-red">hsl()</div> <div data-color="hwb-red">hwb()</div> <div data-color="lch-red">lch()</div> <div data-color="oklch-red">oklch()</div> ``` #### CSS ```css [data-color="hsl-red"] { /* hsl(<hue> <saturation> <lightness>) */ background-color: hsl(0 100% 50%); } [data-color="hwb-red"] { /* hwb(<hue> <whiteness> <blackness>) */ background-color: hwb(0 0% 0%); } [data-color="lch-red"] { /* lch(<lightness> <chroma> <hue>) */ background-color: lch(50 150 40); } [data-color="oklch-red"] { /* oklch(<lightness> <chroma> <hue>) */ background-color: oklch(0.6 0.4 20); } ``` ```css hidden div { font-family: monospace; width: 100px; height: 100px; margin: 10px; border: 1px solid black; display: inline-block; } ``` #### Result {{EmbedLiveSample("approximating_red_hues_in_different_color_spaces", "100%", "150")}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [`<color>`](/en-US/docs/Web/CSS/color_value) - {{CSSXref("&lt;hue-interpolation-method&gt;")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/hue/color_wheel.svg
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400"> <style> text { font: 20px sans-serif; } div { border-radius: 50%; height: 100%; width: 100%; background: conic-gradient(red, #ff0, green, #0ff, blue, #f0f, red); } </style> <path fill="#fff" d="M0 0h400v400H0z" /> <foreignObject width="320" height="320" x="40" y="40"> <div xmlns="http://www.w3.org/1999/xhtml" /> </foreignObject> <text x="200" y="30" text-anchor="middle">0°</text> <text x="347" y="115" dominant-baseline="middle">60°</text> <text x="347" y="285" dominant-baseline="middle">120°</text> <text x="200" y="370" dominant-baseline="hanging" text-anchor="middle"> 180° </text> <text x="53" y="285" dominant-baseline="middle" text-anchor="end">240°</text> <text x="53" y="115" dominant-baseline="middle" text-anchor="end">300°</text> </svg>
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/css_table/index.md
--- title: CSS table slug: Web/CSS/CSS_table page-type: css-module spec-urls: https://www.w3.org/TR/CSS22/tables.html --- {{CSSRef}} The **CSS table** module helps you define how to lay out table data. ## Reference ### Properties - {{cssxref("border-collapse")}} - {{cssxref("border-spacing")}} - {{cssxref("caption-side")}} - {{cssxref("empty-cells")}} - {{cssxref("table-layout")}} - {{cssxref("vertical-align")}} ## Specifications {{Specifications}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/row-gap/index.md
--- title: row-gap slug: Web/CSS/row-gap page-type: css-property browser-compat: css.properties.row-gap --- {{CSSRef}} The **`row-gap`** [CSS](/en-US/docs/Web/CSS) property sets the size of the gap ({{glossary("gutters","gutter")}}) between an element's rows. Early versions of the specification called this property `grid-row-gap`, and to maintain compatibility with legacy websites, browsers will still accept `grid-row-gap` as an alias for `row-gap`. {{EmbedInteractiveExample("pages/css/row-gap.html")}} ## Syntax ```css /* <length> values */ row-gap: 20px; row-gap: 1em; row-gap: 3vmin; row-gap: 0.5cm; /* <percentage> value */ row-gap: 10%; /* Global values */ row-gap: inherit; row-gap: initial; row-gap: revert; row-gap: revert-layer; row-gap: unset; ``` ### Values - `<length-percentage>` - : Is the width of the gutter separating the rows. {{CSSxRef("&lt;percentage&gt;")}} values are relative to the dimension of the element. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Flex layout #### HTML ```html <div id="flexbox"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> ``` #### CSS ```css #flexbox { display: flex; flex-wrap: wrap; width: 300px; row-gap: 20px; } #flexbox > div { border: 1px solid green; background-color: lime; flex: 1 1 auto; width: 100px; height: 50px; } ``` #### Result {{EmbedLiveSample('Flex_layout', "auto", "120px")}} ### Grid layout #### HTML ```html <div id="grid"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> ``` #### CSS ```css #grid { display: grid; height: 200px; grid-template-columns: 150px 1fr; grid-template-rows: repeat(3, 1fr); row-gap: 20px; } #grid > div { border: 1px solid green; background-color: lime; } ``` #### Result {{EmbedLiveSample('Grid_layout', 'auto', 120)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - Related CSS properties: {{CSSxRef("column-gap")}}, {{CSSxRef("gap")}} - Grid Layout Guide: _[Basic concepts of grid layout - Gutters](/en-US/docs/Web/CSS/CSS_grid_layout/Basic_concepts_of_grid_layout#gutters)_
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/scroll-behavior/index.md
--- title: scroll-behavior slug: Web/CSS/scroll-behavior page-type: css-property browser-compat: css.properties.scroll-behavior --- {{CSSRef}} The **`scroll-behavior`** [CSS](/en-US/docs/Web/CSS) property sets the behavior for a scrolling box when scrolling is triggered by the navigation or CSSOM scrolling APIs. {{EmbedInteractiveExample("pages/css/scroll-behavior.html")}} Note that any other scrolls, such as those performed by the user, are not affected by this property. When this property is specified on the root element, it applies to the viewport instead. This property specified on the `body` element will _not_ propagate to the viewport. User agents are allowed to ignore this property. ## Syntax ```css /* Keyword values */ scroll-behavior: auto; scroll-behavior: smooth; /* Global values */ scroll-behavior: inherit; scroll-behavior: initial; scroll-behavior: revert; scroll-behavior: revert-layer; scroll-behavior: unset; ``` The `scroll-behavior` property is specified as one of the keyword values listed below. ### Values - `auto` - : The scrolling box scrolls instantly. - `smooth` - : The scrolling box scrolls in a smooth fashion using a user-agent-defined easing function over a user-agent-defined period of time. User agents should follow platform conventions, if any. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Setting smooth scroll behavior #### HTML ```html <nav> <a href="#page-1">1</a> <a href="#page-2">2</a> <a href="#page-3">3</a> </nav> <div class="scroll-container"> <div class="scroll-page" id="page-1">1</div> <div class="scroll-page" id="page-2">2</div> <div class="scroll-page" id="page-3">3</div> </div> ``` #### CSS ```css a { display: inline-block; width: 50px; text-decoration: none; } nav, .scroll-container { display: block; margin: 0 auto; text-align: center; } nav { width: 339px; padding: 5px; border: 1px solid black; } .scroll-container { width: 350px; height: 200px; overflow-y: scroll; scroll-behavior: smooth; } .scroll-page { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 5em; } ``` #### Result {{ EmbedLiveSample("Setting_smooth_scroll_behavior", "100%", 250) }} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/border-top-left-radius/index.md
--- title: border-top-left-radius slug: Web/CSS/border-top-left-radius page-type: css-property browser-compat: css.properties.border-top-left-radius --- {{CSSRef}} The **`border-top-left-radius`** [CSS](/en-US/docs/Web/CSS) property rounds the top-left corner of an element by specifying the radius (or the radius of the semi-major and semi-minor axes) of the ellipse defining the curvature of the corner. {{EmbedInteractiveExample("pages/css/border-top-left-radius.html")}} The rounding can be a circle or an ellipse, or if one of the value is `0`, no rounding is done and the corner is square. ![border-radius.png](border-radius.png) A background, being an image or a color, is clipped at the border, even a rounded one; the exact location of the clipping is defined by the value of the {{cssxref("background-clip")}} property. > **Note:** If the value of this property is not set in a {{cssxref("border-radius")}} shorthand property that is applied to the element after the `border-top-left-radius` CSS property, the value of this property is then reset to its initial value by the [shorthand property](/en-US/docs/Web/CSS/Shorthand_properties). ## Syntax ```css /* the corner is a circle */ /* border-top-left-radius: radius */ border-top-left-radius: 3px; /* the corner is an ellipse */ /* border-top-left-radius: horizontal vertical */ border-top-left-radius: 0.5em 1em; border-top-left-radius: inherit; /* Global values */ border-top-left-radius: inherit; border-top-left-radius: initial; border-top-left-radius: revert; border-top-left-radius: revert-layer; border-top-left-radius: unset; ``` With one value: - the value is a {{cssxref("&lt;length&gt;")}} or a {{cssxref("&lt;percentage&gt;")}} denoting the radius of the circle to use for the border in that corner. With two values: - the first value is a {{cssxref("&lt;length&gt;")}} or a {{cssxref("&lt;percentage&gt;")}} denoting the horizontal semi-major axis of the ellipse to use for the border in that corner. - the second value is a {{cssxref("&lt;length&gt;")}} or a {{cssxref("&lt;percentage&gt;")}} denoting the vertical semi-major axis of the ellipse to use for the border in that corner. ### Values - `<length-percentage>` - : Denotes the size of the circle radius or the semi-major and semi-minor axes of the ellipse. As absolute length it can be expressed in any unit allowed by the CSS {{cssxref("&lt;length&gt;")}} data type. Percentages for the horizontal axis refer to the width of the box, percentages for the vertical axis refer to the height of the box. Negative values are invalid. ## Formal definition {{CSSInfo}} ## Formal syntax {{csssyntax}} ## Examples ### Arc of a circle A single `<length>` value produces an arc of a circle. ```html hidden <div></div> ``` ```css div { border-top-left-radius: 40px; background-color: lightgreen; border: solid 1px black; width: 100px; height: 100px; } ``` {{EmbedLiveSample("Arc_of_a_circle")}} ### Arc of an ellipse Two different `<length>` values produce an arc of an ellipse. ```html hidden <div></div> ``` ```css div { border-top-left-radius: 40px 20px; background-color: lightgreen; border: solid 1px black; width: 100px; height: 100px; } ``` {{EmbedLiveSample("Arc_of_an_ellipse")}} ### Square element with percentage radius A square element with a single `<percentage>` value produces an arc of a circle. ```html hidden <div></div> ``` ```css div { border-top-left-radius: 40%; background-color: lightgreen; border: solid 1px black; width: 100px; height: 100px; } ``` {{EmbedLiveSample("Square_element_with_percentage_radius")}} ### Non-square element with percentage radius A non-square element with a single `<percentage>` value produces an arc of an ellipse. ```html hidden <div></div> ``` ```css div { border-top-left-radius: 40%; background-color: lightgreen; border: solid 1px black; width: 200px; height: 100px; } ``` {{EmbedLiveSample("Non-square_element_with_percentage_radius")}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref("border-radius")}} shorthand property - {{cssxref("border-top-right-radius")}}, {{cssxref("border-bottom-right-radius")}}, and {{cssxref("border-bottom-left-radius")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_doublecolon_-moz-list-number/index.md
--- title: "::-moz-list-number" slug: Web/CSS/::-moz-list-number page-type: css-pseudo-element status: - non-standard --- {{CSSRef}}{{Non-standard_header}} The **`::-moz-list-number`** [CSS](/en-US/docs/Web/CSS) [pseudo-element](/en-US/docs/Web/CSS/Pseudo-elements) is a [Mozilla extension](/en-US/docs/Web/CSS/Mozilla_Extensions) that represents the marker (typically a number) of a list item ({{HTMLElement("li")}}) in an ordered list ({{HTMLElement("ol")}}). ## Syntax ```css li::-moz-list-number { /* ... */ } ``` ## Examples ### HTML ```html <ol> <li>First item</li> <li>Second item</li> <li>Third item</li> </ol> ``` ### CSS ```css li::-moz-list-number { font-style: italic; font-weight: bold; } ``` ### Result {{ EmbedLiveSample("Examples", "auto", "auto", "moz-list-number.png") }} ## Specifications Not part of any standard. ## See also - {{cssxref("::-moz-list-bullet")}} - {{cssxref("::marker")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/string/index.md
--- title: <string> slug: Web/CSS/string page-type: css-type browser-compat: css.types.string --- {{CSSRef}} The **`<string>`** [CSS](/en-US/docs/Web/CSS) [data type](/en-US/docs/Web/CSS/CSS_Types) represents a sequence of characters. Strings are used in numerous CSS properties, such as {{CSSxRef("content")}}, {{CSSxRef("font-family")}}, and {{CSSxRef("quotes")}}. ## Syntax The `<string>` data type is composed of any number of [Unicode](https://en.wikipedia.org/wiki/Unicode) characters surrounded by either double (`"`) or single (`'`) quotes. Most characters can be represented literally. All characters can also be represented with their respective [Unicode code points](https://en.wikipedia.org/wiki/Unicode#Code_point_planes_and_blocks) in hexadecimal, in which case they are preceded by a backslash (`\`). For example, `\22` represents a double quote, `\27` a single quote (`'`), and `\A9` the copyright symbol (`©`). Importantly, certain characters which would otherwise be invalid can be escaped with a backslash. These include double quotes when used inside a double-quoted string, single quotes when used inside a single-quoted string, and the backslash itself. For example, `\\` will create a single backslash. To output new lines, you must escape them with a line feed character such as `\A` or `\00000A`. In your code, however, strings can span multiple lines, in which case each new line must be escaped with a `\` as the last character of the line. However, to get new lines, you must also set the {{cssxref("white-space")}} property to appropriate value. > **Note:** [HTML entities](/en-US/docs/Glossary/Entity) (such as `&nbsp;` or `&#8212;`) cannot be used in a CSS `<string>`. ## Examples ### Examples of valid strings ```css /* Simple strings */ "This string is demarcated by double quotes." 'This string is demarcated by single quotes.' /* Character escaping */ "This is a string with \" an escaped double quote." "This string also has \22 an escaped double quote." 'This is a string with \' an escaped single quote.' 'This string also has \27 an escaped single quote.' "This is a string with \\ an escaped backslash." /* New line in a string */ "This string has a \Aline break in it." /* String spanning two lines of code (these two strings will have identical output) */ "A really long \ awesome string" "A really long awesome string" ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS Units and Values](/en-US/docs/Web/CSS/CSS_Values_and_Units) - [CSS Basic Data Types](/en-US/docs/Web/CSS/CSS_Types) - [Introduction to CSS: Values and Units](/en-US/docs/Learn/CSS/Building_blocks/Values_and_units)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/overflow-block/index.md
--- title: overflow-block slug: Web/CSS/overflow-block page-type: css-property browser-compat: css.properties.overflow-block --- {{CSSRef}} The **`overflow-block`** [CSS](/en-US/docs/Web/CSS) property sets what shows when content overflows the block start and block end edges of a box. This may be nothing, a scroll bar, or the overflow content. > **Note:** The `overflow-block` property maps to {{Cssxref("overflow-y")}} or {{Cssxref("overflow-x")}} depending on the writing mode of the document. ## Syntax ```css /* Keyword values */ overflow-block: visible; overflow-block: hidden; overflow-block: clip; overflow-block: scroll; overflow-block: auto; /* Global values */ overflow-block: inherit; overflow-block: initial; overflow-block: revert; overflow-block: revert-layer; overflow-block: unset; ``` The `overflow-block` property is specified as a single {{CSSXref("overflow_value", "&lt;overflow&gt;")}} keyword value: ### Values - `visible` - : Content is not clipped and may be rendered outside the padding box's block start and block end edges. - `hidden` - : Content is clipped if necessary to fit the block dimension in the padding box. No scrollbars are provided. - `clip` - : Overflow content is clipped at the element's overflow clip edge that is defined using the {{CSSXref("overflow-clip-margin")}} property. - `scroll` - : Content is clipped if necessary to fit in the block dimension in the padding box. Browsers display scrollbars whether or not any content is actually clipped. (This prevents scrollbars from appearing or disappearing when the content changes.) Printers may still print overflowing content. - `auto` - : Depends on the user agent. If content fits inside the padding box, it looks the same as `visible`, but still establishes a new block-formatting context. ## Formal definition {{CSSInfo}} ## Formal syntax {{csssyntax}} ## Examples ### HTML ```html <ul> <li> <code>overflow-block: hidden</code> (hides the text outside the box) <div id="hidden"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </div> </li> <li> <code>overflow-block: scroll</code> (always adds a scrollbar) <div id="scroll"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </div> </li> <li> <code>overflow-block: clip</code> (hides the text outside the box beyond the overflow clip edge) <div id="clip"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </div> </li> <li> <code>overflow-block: visible</code> (displays the text outside the box if needed) <div id="visible"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </div> </li> <li> <code>overflow-block: auto</code> (on most browsers, equivalent to <code>scroll</code>) <div id="auto"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </div> </li> </ul> ``` ### CSS ```css div { border: 1px solid black; width: 250px; height: 100px; margin-bottom: 120px; } #hidden { overflow-block: hidden; } #scroll { overflow-block: scroll; } #scroll { overflow-block: clip; } #visible { overflow-block: visible; } #auto { overflow-block: auto; } ``` ### Result {{EmbedLiveSample("Examples", "100%", "780")}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref("text-overflow")}}, {{cssxref("white-space")}}, {{Cssxref("overflow")}}, {{Cssxref("overflow-inline")}}, {{Cssxref("overflow-x")}}, {{Cssxref("overflow-y")}}, {{Cssxref("clip")}}, {{Cssxref("display")}} - [CSS logical properties](/en-US/docs/Web/CSS/CSS_logical_properties_and_values) - [CSS overflow](/en-US/docs/Web/CSS/CSS_overflow) module - [CSS scrollbars style](/en-US/docs/Web/CSS/CSS_scrollbars_styling) module - [CSS writing modes](/en-US/docs/Web/CSS/CSS_writing_modes) - [CSS building blocks: Overflowing content](/en-US/docs/Learn/CSS/Building_blocks/Overflowing_content)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/css_multicol_layout/index.md
--- title: CSS multi-column layout slug: Web/CSS/CSS_multicol_layout page-type: css-module spec-urls: https://drafts.csswg.org/css-multicol/ --- {{CSSRef}} The **CSS multi-column layout** module lets you divide content across multiple columns. By using the properties in this module, you can define the preferred number and width of columns, the gap size between columns, and the visual appearance of the optional column dividing lines (known as column rules). You can also define how content should flow from column to column and how to break content between columns. ## Multi-column layout in action In this example, the 1967 speech from Canada's centennial, _A Lament for Confederation_, by Chief Dan George, is displayed across multiple columns, similar to the way articles are displayed in printed newspapers. If you have JavaScript enabled, controls enable changing the preferred column number and width, the width of the gap between columns, whether the title and a sample blockquote should be contained in a single column or made to span all columns, and whether breaking within the paragraphs should be avoided. {{EmbedGHLiveSample("css-examples/modules/multicol.html", '100%', 650)}} To see the code for this columned layout, [view the source on GitHub](https://github.com/mdn/css-examples/blob/main/modules/multicol.html). > **Note:** Multiple-column layout is closely related to [paged media](/en-US/docs/Web/CSS/CSS_paged_media). Each column box is a fragment, much like each printed page is a fragment of a document. Using the properties defined in the [CSS fragmentation](/en-US/docs/Web/CSS/CSS_fragmentation) module, you can control how content breaks between columns and pages. ## Reference ### Properties - {{cssxref("break-after")}} - {{cssxref("break-before")}} - {{cssxref("break-inside")}} - {{cssxref("column-fill")}} - {{cssxref("column-gap")}} - {{cssxref("column-span")}} - {{cssxref("column-rule")}} shorthand - {{cssxref("column-rule-color")}} - {{cssxref("column-rule-style")}} - {{cssxref("column-rule-width")}} - {{cssxref("columns")}} shorthand - {{cssxref("column-count")}} - {{cssxref("column-width")}} > **Note:** Bear in mind that setting container height and line length can pose challenges for people with visual or cognitive disabilities. [WCAG Success Criterion 1.4.8](/en-US/docs/Web/Accessibility/Understanding_WCAG/Perceivable#guideline_1.4_make_it_easier_for_users_to_see_and_hear_content_including_separating_foreground_from_background) states that even when the text size is doubled, content should not need to be scrolled. ## Guides - [Basic concepts of multi-column layout](/en-US/docs/Web/CSS/CSS_multicol_layout/Basic_concepts) - : An overview of the Multiple-column Layout specification - [Styling columns](/en-US/docs/Web/CSS/CSS_multicol_layout/Styling_columns) - : How to use column rules and manage the spacing between columns. - [Spanning and balancing](/en-US/docs/Web/CSS/CSS_multicol_layout/Spanning_balancing_columns) - : How to make elements span across all columns and control the way columns are filled. - [Handling overflow in multi-column layout](/en-US/docs/Web/CSS/CSS_multicol_layout/Handling_overflow_in_multicol_layout) - : What happens when an item overflows the column it is in and what happens when there is too much columned content to fit a container. - [Handling content breaks in multi-column layout](/en-US/docs/Web/CSS/CSS_multicol_layout/Handling_content_breaks_in_multicol_layout) - : Introduction to the Fragmentation specification and how to control where column content breaks. ## Related concepts - {{cssxref("orphans")}} CSS property - {{cssxref("widows")}} CSS property - {{cssxref("overflow")}} CSS property - {{cssxref("gap")}} CSS property - {{cssxref("height")}}, {{cssxref("max-height")}}, and {{cssxref("block-size")}} CSS properties - {{cssxref("width")}}, {{cssxref("max-width")}}, and {{cssxref("inline-size")}} CSS properties - {{cssxref("line-style")}} enumerated data type - [Block formatting context](/en-US/docs/Web/CSS/CSS_display/Block_formatting_context) guide ## Specifications {{Specifications}} ## See also - [Learn: multiple-column layout](/en-US/docs/Learn/CSS/CSS_layout/Multiple-column_Layout) - [CSS fragmentation](/en-US/docs/Web/CSS/CSS_fragmentation) module - [CSS flexible box layout](/en-US/docs/Web/CSS/CSS_flexible_box_layout) module - [CSS grid layout](/en-US/docs/Web/CSS/CSS_grid_layout) module - [CSS paged media](/en-US/docs/Web/CSS/CSS_paged_media) module
0
data/mdn-content/files/en-us/web/css/css_multicol_layout
data/mdn-content/files/en-us/web/css/css_multicol_layout/using_multicol_layouts/index.md
--- title: Using multi-column layouts slug: Web/CSS/CSS_multicol_layout/Using_multicol_layouts page-type: guide --- {{CSSRef}} The properties defined in the **CSS multi-column layout module** extend the _block layout mode_ , enabling the easy definition of multiple columns of text. People have trouble reading text if lines are too long. If it takes too long for the eyes to move from the end of one line to the beginning of the next, readers can lose track of which line they were on. To provide for a better user experience when reading text making use of a large screen, you should limit the width of text by using columns of text placed side by side, just as newspapers do. ## Using columns ### Column count and width Two CSS properties control whether and how many columns will appear: {{cssxref("column-count")}} and {{cssxref("column-width")}}. The `column-count` property sets the number of columns to a particular number. E.g., ## Example 1 ### HTML ```html <div id="col"> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p> <p> Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p> <p> Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p> <p> Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> </div> ``` ### CSS ```css #col { column-count: 2; } ``` ### Result The content will be displayed in two columns: {{EmbedLiveSample("Example_1", "100%")}} The `column-width` property sets the minimum desired column width. If `column-count` is not also set, then the browser will automatically make as many columns as fit in the available width. ## Example 2 ### HTML ```html <div id="wid"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </div> ``` ### CSS ```css #wid { column-width: 100px; } ``` ### Result {{EmbedLiveSample("Example_2", "100%")}} In a multi-column block, content automatically flows from one column into the next as needed. All HTML, CSS, and DOM functionality is supported within columns, as are editing and printing. ### The columns shorthand You can use either {{cssxref("column-count")}} or {{cssxref("column-width")}}. Because values for these properties do not overlap, it is often convenient to use the shorthand {{cssxref("columns")}}. ## Example 3 In this example, the CSS declaration `column-width: 12em` is replaced by `columns: 12em`. ### HTML ```html <div id="col_short"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </div> ``` ### CSS ```css #col_short { columns: 12em; } ``` {{EmbedLiveSample("Example_3", "100%")}} ## Example 4 In this example, the CSS declaration `column-count: 4` is replaced by `columns: 4`. ### HTML ```html <div id="columns_4"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </div> ``` ### CSS ```css #columns_4 { columns: 4; } ``` ### Result {{EmbedLiveSample("Example_4", "100%")}} ## Example 5 The two CSS declarations `column-width: 8em` and `column-count: 12` can be replaced by `columns: 12 8em`. The `column-count` portion of the shorthand is the maximum number of columns that will be present. The `column-width` is the minimum width each column should be. ### HTML ```html <div id="columns_12"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </div> ``` ### CSS ```css #columns_12 { columns: 12 8em; } ``` ### Result {{EmbedLiveSample("Example_5", "100%")}} Assuming a default `1em` gap between columns, if the container is wider than `103ems` (12 columns \* `8em` width each + 7 `1em` gaps), there will be 12 columns, each with a width of `8ems` or more. If the container is less than `103ems` wide, there will be fewer than 12 columns. If the container is less than `17ems` wide (`8em` column + `8em` column + `1em` gap), the content will be displayed as a single column with no column gap. ### Height balancing CSS columns require that the column heights must be balanced: that is, the browser automatically sets the maximum column height so that the heights of the content in each column are approximately equal. Firefox does this. However, in some situations it is also useful to set the maximum height of the columns explicitly, and then lay out content starting at the first column and creating as many columns as necessary, possibly overflowing to the right. Therefore, if the height is constrained, by setting the CSS {{cssxref("height")}} or {{cssxref("max-height")}} properties on a multi-column block, each column is allowed to grow to that height and no further before adding new column. This mode is also much more efficient for layout. ### Column Gaps There is a gap between columns. The recommended default is `1em`. This size can be changed by applying the {{cssxref("column-gap")}} property to the multi-column block: ## Example 6 ### HTML ```html <div id="column_gap"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </div> ``` ### CSS ```css #column_gap { column-count: 5; column-gap: 2em; } ``` ### Result {{EmbedLiveSample("Example_6", "100%")}} ## Conclusion CSS columns are a layout primitive that can help make large blocks of text easier to read when responsive content is viewed on wide viewports. Imaginative developers may find many uses for them, especially in conjunction with [container queries](/en-US/docs/Web/CSS/CSS_containment/Container_queries) and with the automatic height balancing feature.
0
data/mdn-content/files/en-us/web/css/css_multicol_layout
data/mdn-content/files/en-us/web/css/css_multicol_layout/handling_content_breaks_in_multicol_layout/index.md
--- title: Handling content breaks in multi-column layout slug: Web/CSS/CSS_multicol_layout/Handling_content_breaks_in_multicol_layout page-type: guide --- {{CSSRef}} Content between column boxes in a multicol layout breaks in the same way that it breaks between pages in paged media. In both contexts, you can control where and how content breaks by using properties of the [CSS fragmentation](/en-US/docs/Web/CSS/CSS_fragmentation) module. In this guide, we see how fragmentation works in a _multi-column container_ or _multicol container_ for short. ## Fragmentation basics The CSS fragmentation module provides details on how content breaks between the fragmentation containers or _fragmentainers_. The [multi-column layout](/en-US/docs/Web/CSS/CSS_multicol_layout) module, on the other hand, defines the {{cssxref("break-after")}}, {{cssxref("break-before")}}, and {{cssxref("break-inside")}} properties that provide some control within and between columns. In multicol layout, a column box is a fragment container. A column box can contain other markup and there are many places where a break would not be ideal. For example, we would generally prefer that the caption of an image not be separated into a new column away from the image it refers to. Also, ending a column with a heading looks strange. The multicol fragmentation properties give us ways to exercise some control over this. There are various places we might want to control our breaks: - Breaks inside boxes, for example inside a figure element. - Breaks before and after boxes, which would include our heading example above. - Breaks between lines. ## Breaks inside boxes To control breaks inside boxes use the {{cssxref("break-inside")}} property. This property takes values of: - `auto` - `avoid` - `avoid-page` - `avoid-column` - `avoid-region` In the example below, we have applied break-inside to the figure element to prevent the caption from becoming separated from the image. {{EmbedGHLiveSample("css-examples/multicol/fragmentation/break-inside.html", '100%', 800)}} ## Breaks before and after boxes The {{cssxref("break-before")}} and {{cssxref("break-after")}} properties are used to control breaks before and after elements. They take the following values when in a multicol context: - auto - avoid - avoid-column - column In this next example, we are forcing a column break before an `h2` element. {{EmbedGHLiveSample("css-examples/multicol/fragmentation/break-before.html", '100%', 800)}} ## Breaks between lines The {{cssxref("orphans")}} and {{cssxref("widows")}} properties, part of the CSS fragmentation module, are also useful and worth mentioning. The `orphans` property controls the number of lines left on their own at the end of a fragment. The `widows` property controls the number left on their own at the start of a fragment. The `orphans` and `widows` properties take an {{CSSXref("integer")}} as a value, which represents the number of lines to keep together at the end and start of a fragment, respectively. Note that these properties only work inside a block container, such as a paragraph. If the block has fewer lines in it than the number that you specify as a value, all lines will be kept together. In the example below, we are using the `orphans` property to control the number of lines left at the bottom of a column. You can change that value to see the effect on the breaking of the content. {{EmbedGHLiveSample("css-examples/multicol/fragmentation/orphans.html", '100%', 800)}} ## When things don't work as expected If you have small amounts of content and are trying to control breaks on several elements, your content needs to break somewhere, so you may not always get the result you intended. To some extent, your use of fragmentation is always a suggestion to the browser, to control breaks in this way if it is possible. If the content doesn't break where you intended, the result may be untidy, but the content is still available for your users.
0
data/mdn-content/files/en-us/web/css/css_multicol_layout
data/mdn-content/files/en-us/web/css/css_multicol_layout/basic_concepts/index.md
--- title: Basic concepts of multi-column layout slug: Web/CSS/CSS_multicol_layout/Basic_concepts page-type: guide --- {{CSSRef}} Multi-column layout, usually referred to as multicol layout, is a specification for laying out content into a set of column boxes much like columns in a newspaper. This guide explains how the specification works with some common use case examples. ## Key properties Multicol layout is unlike any of the other layout methods in CSS; it fragments the content, including all descendant elements, into columns. This happens in the same way that content is fragmented into pages when we work with [CSS paged media](/en-US/docs/Web/CSS/CSS_paged_media) by creating a print stylesheet. In this and subsequent guides, we will be discussing the following properties defined in the [CSS multi-column layout](/en-US/docs/Web/CSS/CSS_multicol_layout) module: - {{cssxref("column-width")}} - {{cssxref("column-count")}} - {{cssxref("columns")}} shorthand - {{cssxref("column-rule-color")}} - {{cssxref("column-rule-style")}} - {{cssxref("column-rule-width")}} - {{cssxref("column-rule")}} shorthand - {{cssxref("column-span")}} - {{cssxref("column-fill")}} - {{cssxref("column-gap")}} - {{cssxref("break-after")}} - {{cssxref("break-before")}} - {{cssxref("break-inside")}} ## Defining columns By adding the `column-count` or the `column-width` property to an element, or using the `columns` shorthand, the element becomes a _multi-column container_ or _multicol container_ for short. The columns are anonymous boxes; they're described as _column boxes_ in the specification. ### Specifying the number of columns The `column-count` property specifies the number of columns that you would like the content to be displayed as. The browser will then assign the correct amount of space to each column box to create the requested number of columns. In the below example, we use the `column-count` property to create three columns on the `.container` element. The content, including the children of `.container`, is then split between the three columns. {{EmbedGHLiveSample("css-examples/multicol/basics/column-count.html", '100%', 550)}} In the above example, the content is wrapped within the paragraph `<p>` tags with the default styling. Therefore, there is a margin above each paragraph. You can see how this margin causes the first line of text to be pushed down. This is because a multicol container creates a [block formatting context (BFC)](/en-US/docs/Web/CSS/CSS_display/Block_formatting_context) because of which margins on child elements do not collapse with any margin on the container. ### Specifying the width of columns The `column-width` property is used to set the optimal width for every column box. If you declare a column width, the browser will work out how many columns of that width will fit into the multicol container and distribute any extra space equally between the columns. Therefore, the column width should be seen as minimum width because the column boxes are likely to be wider due to the additional space. In the case of a single column with less width available than the value of `column-width`, the column box will shrink to be smaller than the declared column width. In the example below, the `column-width` property is set to `200px`. We get as many 200-pixel columns as will fit the container, with the extra space shared equally. {{EmbedGHLiveSample("css-examples/multicol/basics/column-width.html", '100%', 550)}} ### Specifying both number and width of columns If you specify both the properties on a multicol container, then `column-count` will act as a maximum number of columns. Therefore, the behavior as described for `column-width` will happen, until the number of columns in `column-count` is reached. After this point, no more columns will be drawn, and the extra space is distributed evenly between the existing columns, even if there is enough room for more columns of the specified `column-width` size. When using both properties together, you may get fewer columns than specified in the value for `column-count`. In this next example, we use `column-width` of `200px` and `column-count` of `2`. Even if there is space for more than two columns, we get two. If there is not enough space for two columns of at least 200 pixels each, we get one. {{EmbedGHLiveSample("css-examples/multicol/basics/column-count-width.html", '100%', 550)}} ### Shorthand for column properties You can use the `columns` shorthand to set the `column-count` and `column-width` values. If you specify a length unit, the value will be used for `column-width`, and if you specify an integer, the value will be used for `column-count`. You can set both the properties, separating the two values with a space. This CSS would give the same result as [example 1](#specifying_the_number_of_columns), with `column-count` set to `3`. ```css .container { columns: 3; } ``` This CSS would give the same result as [example 2](#specifying_the_width_of_columns), with `column-width` of `200px`. ```css .container { columns: 200px; } ``` This CSS would give the same result as [example 3](#specifying_both_number_and_width_of_columns), with both `column-count` and `column-width` set. ```css .container { columns: 2 200px; } ``` ## Next steps In this guide, we've learned the basic use of multi-column layout. In the next guide, we will look at how much we can [style the columns themselves](/en-US/docs/Web/CSS/CSS_multicol_layout/Styling_columns).
0
data/mdn-content/files/en-us/web/css/css_multicol_layout
data/mdn-content/files/en-us/web/css/css_multicol_layout/handling_overflow_in_multicol_layout/index.md
--- title: Handling overflow in multi-column layout slug: Web/CSS/CSS_multicol_layout/Handling_overflow_in_multicol_layout page-type: guide --- {{CSSRef}} In this guide, we look at how to deal with overflow in a multi-column (_multicol_) layout, both inside the column boxes and in situations where there is more content than will fit into the container. ## Overflow inside column boxes An overflow situation happens when an item's size is larger than the column box. For example, the situation could happen when an image in a column is wider than the `column-width` value or the width of the column based on the number of columns declared with `column-count`. In this situation, the content should visibly overflow into the next column, rather than be clipped by the column box. {{EmbedGHLiveSample("css-examples/multicol/overflow/image.html", '100%', 800)}} There are two columns of text. In the left column, there is a photo that is wider than the column. The image expands into that second column, appearing behind the text of the right column. The flow of text in the right column isn't affected by the protruding photo, but the appearance is. If you want an image to fit the column box, setting `max-width: 100%` will prevent the image from growing beyond its container, in this case, the column box. {{EmbedGHLiveSample("css-examples/multicol/overflow/image-max-width.html", '100%', 800)}} ## More columns than will fit How overflowing columns are handled depends on whether the media context is fragmented, such as print, or is continuous, such as a web page. In fragmented media, after a fragment (for example, a page) is filled with columns, the columns will move to a new page and fill that up with columns. In continuous media, columns will overflow in the inline direction. On the web, this means that you will get a horizontal scrollbar. The example below shows this overflow behavior. The multicol container has a set {{CSSXref("height")}} and there is more text than space to create columns; therefore, we get columns created outside of the container. {{EmbedGHLiveSample("css-examples/multicol/overflow/overflow-inline.html", '100%', 800)}} ## Using vertical media queries One issue with multicol on the web is that if the columns are taller than the viewport, the reader will need to scroll the page up and down to read, which is not a good user experience. One way to avoid this is to only apply the column properties if you know there is enough vertical space. In the example below, we used a {{CSSXref("min-height")}} [@media query](/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries) to ensure there is enough vertical space before applying the column properties. {{EmbedGHLiveSample("css-examples/multicol/overflow/min-height.html", '100%', 800)}} ## Next steps In the final guide in this series, we will see [how fragmentation works with multicol layouts](/en-US/docs/Web/CSS/CSS_multicol_layout/Handling_content_breaks_in_multicol_layout) to give us control over how content breaks between columns.
0
data/mdn-content/files/en-us/web/css/css_multicol_layout
data/mdn-content/files/en-us/web/css/css_multicol_layout/spanning_balancing_columns/index.md
--- title: Spanning and balancing columns slug: Web/CSS/CSS_multicol_layout/Spanning_balancing_columns page-type: guide --- {{CSSRef}} In this guide, we look at how to make elements span across columns inside the multi-column (_multicol_) container and how to control how the columns are filled. ## Spanning the columns To cause an item to span across columns, use the {{cssxref("column-span")}} property with a value of `all`. This will cause the element to become a _spanner_, spanning all the columns. Any descendant element of the multicol container may be turned into a spanner, including both direct and indirect children. For example, a heading nested directly inside the container could become a spanner, as could a heading nested inside a {{HTMLElement("section")}} nested inside the multicol container. In the example below, the `<h2>` element is set to `column-span: all` and spans all of the columns. {{EmbedGHLiveSample("css-examples/multicol/spanning/h2-span.html", '100%', 800)}} In this second example, the heading is inside an {{HTMLElement("article")}} element, yet still spans the content as expected. {{EmbedGHLiveSample("css-examples/multicol/spanning/nested-h2-span.html", '100%', 800)}} When a spanner is introduced, it breaks the flow of columns; columns restart after the spanner, effectively creating a new set of column boxes. The content does not jump over a spanning element. ### Limitations of column-span The `column-span` can have only two values. The initial value `none` means the item does not span and remains within a column. The value `all` means the item spans all of the columns. There are no values that enable partial spanning, such as having an item span two out of three columns. ### Things to watch out for If the spanning element is inside another element with margins, padding, and a border or background color, the box may appear above the spanner with the rest of the content being displayed below. For this reason, care should be taken when setting an element to span all the columns, ensuring this scenario is accounted for. {{EmbedGHLiveSample("css-examples/multicol/spanning/mpb-span.html", '100%', 800)}} Additionally, if a spanning element appears later in the content, it can cause unexpected or unwanted behavior when there is not enough content to create columns after the spanner. Use spanning carefully and test at various breakpoints to make sure you get the effect you intended. ## Filling and balancing columns A balanced set of columns is where all columns have approximately the same amount of content. Filling and balancing are relevant when the amount of content does not match the amount of space provided, such as when a {{CSSXref("height")}} is declared on the container. The initial value for {{cssxref("column-fill")}} is `balance`. The value of `balance` means all columns are as balanced as possible. In fragmented contexts, such as [paged media](/en-US/docs/Web/CSS/CSS_paged_media), only the last fragment is balanced. This means that on the last page, the final set of column boxes is balanced. The other balancing value, `balance-all`, balances all columns in fragmented contexts. The columns in this example contain an image and some text, which are balanced. The image, which cannot break, is in the first column. The other columns are balanced, filling with equal amounts of text. {{EmbedGHLiveSample("css-examples/multicol/balancing/balance.html", '100%', 550)}} The `auto` value for `column-fill` fills a column sequentially, filling the first column in the inline-start direction, before placing content in subsequent columns, rather than balancing and filling all the columns equally. In this example, we changed `column-fill` to `auto`. The columns are filled to the height of the container, leaving empty columns at the end. {{EmbedGHLiveSample("css-examples/multicol/balancing/auto.html", '100%', 550)}} ## Next steps In the next guide, you will learn [how multicol handles overflow](/en-US/docs/Web/CSS/CSS_multicol_layout/Handling_overflow_in_multicol_layout) within columns and when there are more columns than can fit in the container.
0
data/mdn-content/files/en-us/web/css/css_multicol_layout
data/mdn-content/files/en-us/web/css/css_multicol_layout/styling_columns/index.md
--- title: Styling columns slug: Web/CSS/CSS_multicol_layout/Styling_columns page-type: guide --- {{CSSRef}} As column boxes created inside multi-column (_multicol_) containers are anonymous boxes, styling individual columns is not possible, but we can style the gaps between the columns and the container in general. This guide explains how to change the gap and style rules between columns. ## Column gaps The gap between columns is controlled using the {{CSSXref("column-gap")}} or {{CSSXref("gap")}} property. The `column-gap` property is defined in the [multi-column layout](/en-US/docs/Web/CSS/CSS_multicol_layout) module. The `gap` property is defined in the [box alignment](/en-US/docs/Web/CSS/CSS_box_alignment) module. This is a unified property to define gaps between boxes in all layouts that support gaps, including [CSS grid layout](/en-US/docs/Web/CSS/CSS_grid_layout/Box_alignment_in_grid_layout) and [CSS flexible box layout](/en-US/docs/Web/CSS/CSS_flexible_box_layout/Mastering_wrapping_of_flex_items). The initial value of `column-gap` is `1em`, which prevents columns from running into each other. In other layout methods, `column-gap` is supported as a synonym for `gap`, but with an initial value of `0`. The keyword value `normal` sets `column-gap` to the initial value. You can change the gap by using any {{cssxref("length")}} value. In the example below, the `column-gap` is set to `40px`. {{EmbedGHLiveSample("css-examples/multicol/styling/column-gap.html", '100%', 750)}} The allowed value for `column-gap` is a {{cssxref("length-percentage")}}, meaning percentages are allowed. Percentage values for `column-gap` are calculated as a percentage of the width of the multicol container. ## Column rules The specification defines {{CSSXref("column-rule-width")}}, {{CSSXref("column-rule-style")}} and {{CSSXref("column-rule-color")}}, providing a shorthand {{CSSXref("column-rule")}}. These properties work in exactly the same way as the {{CSSXref("border")}} properties: any {{CSSXref("line-style")}} can be used as a `column-rule-style`, just as for valid {{CSSXref("border-style")}}. These properties are applied to the element, which is the multicol container, and therefore, all columns will have the same rule. Rules are only drawn between columns and not on the outer edges. Rules are also only drawn between columns that have content. In this next example, a 5px-dotted rule with a color of `rebeccapurple` has been created using the longhand values. {{EmbedGHLiveSample("css-examples/multicol/styling/column-rule.html", '100%', 550)}} Note that the rule itself does not take up any space: a wide rule will not push the columns apart to make space for the rule. Instead, the rule overlays the gap. The example below uses a very wide rule of `40px` and a `10px` gap. The rule displays under the column content. To make space on both sides of the rule, the gap would need to be increased to be larger than `40px`. {{EmbedGHLiveSample("css-examples/multicol/styling/column-rule-wide.html", '100%', 550)}} ## Next steps This article details all the current ways in which column boxes can be styled. In the next guide, we will take a look at making elements inside a container [span across all columns](/en-US/docs/Web/CSS/CSS_multicol_layout/Spanning_balancing_columns).
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/scroll-padding-right/index.md
--- title: scroll-padding-right slug: Web/CSS/scroll-padding-right page-type: css-property browser-compat: css.properties.scroll-padding-right --- {{CSSRef}} The `scroll-padding-right` property defines offsets for the right of the _optimal viewing region_ of the scrollport: the region used as the target region for placing things in view of the user. This allows the author to exclude regions of the scrollport that are obscured by other content (such as fixed-positioned toolbars or sidebars) or to put more breathing room between a targeted element and the edges of the scrollport. {{EmbedInteractiveExample("pages/css/scroll-padding-right.html")}} ## Syntax ```css /* Keyword values */ scroll-padding-right: auto; /* <length> values */ scroll-padding-right: 10px; scroll-padding-right: 1em; scroll-padding-right: 10%; /* Global values */ scroll-padding-right: inherit; scroll-padding-right: initial; scroll-padding-right: revert; scroll-padding-right: revert-layer; scroll-padding-right: unset; ``` ### Values - `<length-percentage>` - : An inwards offset from the top edge of the scrollport, as a valid length or a percentage. - `auto` - : The offset is determined by the user agent. This will generally be 0px, but a user agent is able to detect and do something else if a non-zero value is more appropriate. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS scroll snap](/en-US/docs/Web/CSS/CSS_scroll_snap) - [Well-controlled scrolling with CSS scroll snap](https://web.dev/articles/css-scroll-snap)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/border-block-end-style/index.md
--- title: border-block-end-style slug: Web/CSS/border-block-end-style page-type: css-property browser-compat: css.properties.border-block-end-style --- {{CSSRef}} The **`border-block-end-style`** [CSS](/en-US/docs/Web/CSS) property defines the style of the logical block-end border of an element, which maps to a physical border style depending on the element's writing mode, directionality, and text orientation. It corresponds to the {{cssxref("border-top-style")}}, {{cssxref("border-right-style")}}, {{cssxref("border-bottom-style")}}, or {{cssxref("border-left-style")}} property depending on the values defined for {{cssxref("writing-mode")}}, {{cssxref("direction")}}, and {{cssxref("text-orientation")}}. {{EmbedInteractiveExample("pages/css/border-block-end-style.html")}} ## Syntax ```css /* <'border-style'> values */ border-block-end-style: dashed; border-block-end-style: dotted; border-block-end-style: groove; /* Global values */ border-block-end-style: inherit; border-block-end-style: initial; border-block-end-style: revert; border-block-end-style: revert-layer; border-block-end-style: unset; ``` Related properties are {{cssxref("border-block-start-style")}}, {{cssxref("border-inline-start-style")}}, and {{cssxref("border-inline-end-style")}}, which define the other border styles of the element. ### Values - `<'border-style'>` - : The line style of the border. See {{ cssxref("border-style") }}. ## Formal definition {{CSSInfo}} ## Formal syntax {{csssyntax}} ## Examples ### Dashed border with vertical text #### HTML ```html <div> <p class="exampleText">Example text</p> </div> ``` #### CSS ```css div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 5px solid blue; border-block-end-style: dashed; } ``` #### Results {{EmbedLiveSample("Dashed_border_with_vertical_text", 140, 140)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS Logical Properties and Values](/en-US/docs/Web/CSS/CSS_logical_properties_and_values) - This property maps to one of the physical border properties: {{cssxref("border-top-style")}}, {{cssxref("border-right-style")}}, {{cssxref("border-bottom-style")}}, and {{cssxref("border-left-style")}}. - {{cssxref("writing-mode")}}, {{cssxref("direction")}}, {{cssxref("text-orientation")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/shorthand_properties/index.md
--- title: Shorthand properties slug: Web/CSS/Shorthand_properties page-type: guide --- {{CSSRef}} **_Shorthand properties_** are CSS properties that let you set the values of multiple other CSS properties simultaneously. Using a shorthand property, you can write more concise (and often more readable) style sheets, saving time and energy. The CSS specification defines shorthand properties to group the definition of common properties acting on the same theme. For instance, the CSS {{cssxref("background")}} property is a shorthand property that's able to define the values of {{cssxref("background-color")}}, {{cssxref("background-image")}}, {{cssxref("background-repeat")}}, and {{cssxref("background-position")}}. Similarly, the most common font-related properties can be defined using the shorthand {{cssxref("font")}}, and the different margins around a box can be defined using the {{cssxref("margin")}} shorthand. ## Tricky edge cases There are a few edge cases to keep in mind when using shorthand properties. ### Omitting properties A value which is not specified is set to its initial value. That means that it **overrides** previously set values. For example: ```css p { background-color: red; background: url(images/bg.gif) no-repeat left top; } ``` This will not set the color of the background to `red` but to the default value for {{cssxref("background-color")}}, which is `transparent`. Only the individual properties values can inherit. As missing values are replaced by their initial value, it is impossible to allow inheritance of individual properties by omitting them. The keyword `inherit` can be applied to a property, but only as a whole, not as a keyword for one value or another. That means that the only way to make some specific value to be inherited is to use the longhand property with the keyword `inherit`. ### Ordering properties Shorthand properties try not to force a specific order for the values of the properties they replace. This works well when these properties use values of different types, as the order has no importance, but this does not work as easily when several properties can have identical values. Two important cases here are: - properties related to the edges of a box, like {{cssxref("border-style")}}, {{cssxref("margin")}} or {{cssxref("padding")}} - properties related to the corners of a box, like {{cssxref("border-radius")}} #### Edges of a box Shorthands handling properties related to edges of a box, like {{cssxref("border-style")}}, {{cssxref("margin")}} or {{cssxref("padding")}}, always use a consistent 1-to-4-value syntax representing those edges: - **1-value syntax:** `border-width: 1em` — The single value represents all edges: ![Box edges with one-value syntax](border1.png) - **2-value syntax:** `border-width: 1em 2em` — The first value represents the vertical, that is top and bottom, edges, the second the horizontal ones, that is the left and right ones: ![Box edges with two-value syntax](border2.png) - **3-value syntax:** `border-width: 1em 2em 3em` — The first value represents the top edge, the second, the horizontal, that is left and right, ones, and the third value the bottom edge: ![Box edges with three-value syntax](border3.png) - **4-value syntax:** `border-width: 1em 2em 3em 4em` — The four values represent the top, right, bottom and left edges respectively, always in that order, that is clock-wise starting at the top: ![Box edges with four-value syntax](border4.png) The initial letter of Top-Right-Bottom-Left matches the order of the consonant of the word _trouble_: TRBL. You can also remember it as the order that the hands would rotate on a clock: `1em` starts in the 12 o'clock position, then `2em` in the 3 o'clock position, then `3em` in the 6 o'clock position, and `4em` in the 9 o'clock position. #### Corners of a box Similarly, shorthands handling properties related to corners of a box, like {{cssxref("border-radius")}}, always use a consistent 1-to-4-value syntax representing those corners: - **1-value syntax:** `border-radius: 1em` — The single value represents all corners: ![Box corners with one-value syntax](corner1.png) - **2-value syntax:** `border-radius: 1em 2em` — The first value represents the top left and bottom right corner, the second the top right and bottom left ones: ![Box corners with two-value syntax](corner2.png) - **3-value syntax:** `border-radius: 1em 2em 3em` — The first value represents the top left corner, the second the top right and bottom left ones, and the third value the bottom right corner: ![Box corners with three-value syntax](corner3.png) - **4-value syntax:** `border-radius: 1em 2em 3em 4em` — The four values represent the top left, top right, bottom right and bottom left corners respectively, always in that order, that is clock-wise starting at the top left: ![Box corners with four-value syntax](corner4.png) ## Background properties Consider a background with the following properties ```css background-color: #000; background-image: url(images/bg.gif); background-repeat: no-repeat; background-position: left top; ``` These four declarations can be shortened to just one: ```css background: #000 url(images/bg.gif) no-repeat left top; ``` (The shorthand form is actually the equivalent of the longhand properties above plus `background-attachment: scroll` and, in CSS3, some additional properties.) See {{cssxref("background")}} for more detailed information, including CSS3 properties. ## Font properties Consider the following declarations: ```css font-style: italic; font-weight: bold; font-size: 0.8em; line-height: 1.2; font-family: Arial, sans-serif; ``` These 5 statements can be shortened to the following: ```css font: italic bold 0.8em/1.2 Arial, sans-serif; ``` This shorthand declaration is actually equivalent to the longhand declarations above plus `font-variant: normal`, `font-size-adjust: none`, and `font-stretch: normal`. ## Border properties With borders, the width, color, and style can be simplified into one declaration. For example, consider the following CSS: ```css border-width: 1px; border-style: solid; border-color: #000; ``` It can be simplified as: ```css border: 1px solid #000; ``` ## Margin and padding properties Shorthand versions of margin and padding values work similarly; the margin property allows for shorthand values to be specified using one, two, three, or four values. Consider the following CSS declarations: ```css margin-top: 10px; margin-right: 5px; margin-bottom: 10px; margin-left: 5px; ``` They are the same as the following declaration using the four value shorthand. Note that the values are in clockwise order, beginning at the top: top, right, bottom, then left (TRBL, the consonants in "trouble"). ```css margin: 10px 5px 10px 5px; ``` Margin shorthand rules for one, two, three and four value declarations are: - When **one** value is specified, it applies the same margin to **all four sides**. - When **two** values are specified, the first margin applies to the **top and bottom**, the second to the **left and right**. - When **three** values are specified, the first margin applies to the **top**, the second to the **left and right**, the third to the **bottom**. - When **four** values are specified, the margins apply to the **top**, **right**, **bottom**, and **left** in that order (clockwise). ## Position properties With position, the shorthand versions of top, right, bottom and left can be simplified into one declaration. For example, consider the following CSS: ```css top: 0; right: 20px; bottom: 0; left: 20px; ``` It can be simplified as: ```css inset: 0 20px 0 20px; ``` Just like margins and paddings, the inset values are ordered clockwise - top, right, bottom, then left (TRBL). ## The universal shorthand property CSS provides a universal shorthand property, {{cssxref("all")}}, which applies its value to every property in the document. Its purpose is to change the properties' inheritance model. See [Cascade and inheritance](/en-US/docs/Learn/CSS/Building_blocks/Cascade_and_inheritance) or [Introducing the CSS Cascade](/en-US/docs/Web/CSS/Cascade) for more information about how inheritance works in CSS. ## See also - CSS key concepts: - [CSS syntax](/en-US/docs/Web/CSS/Syntax) - [At-rules](/en-US/docs/Web/CSS/At-rule) - [Comments](/en-US/docs/Web/CSS/Comments) - [Specificity](/en-US/docs/Web/CSS/Specificity) - [Inheritance](/en-US/docs/Web/CSS/Inheritance) - [Box model](/en-US/docs/Web/CSS/CSS_box_model/Introduction_to_the_CSS_box_model) - [Layout modes](/en-US/docs/Web/CSS/Layout_mode) - [Visual formatting models](/en-US/docs/Web/CSS/Visual_formatting_model) - [Margin collapsing](/en-US/docs/Web/CSS/CSS_box_model/Mastering_margin_collapsing) - Values - [Initial values](/en-US/docs/Web/CSS/initial_value) - [Computed values](/en-US/docs/Web/CSS/computed_value) - [Used values](/en-US/docs/Web/CSS/used_value) - [Actual values](/en-US/docs/Web/CSS/actual_value) - [Value definition syntax](/en-US/docs/Web/CSS/Value_definition_syntax) - [Replaced elements](/en-US/docs/Web/CSS/Replaced_element) - Shorthand properties: - {{cssxref("all")}} - {{cssxref("animation")}} - {{cssxref("background")}} - {{cssxref("border")}} - {{cssxref("border-block-end")}} - {{cssxref("border-block-start")}} - {{cssxref("border-bottom")}} - {{cssxref("border-color")}} - {{cssxref("border-image")}} - {{cssxref("border-inline-end")}} - {{cssxref("border-inline-start")}} - {{cssxref("border-left")}} - {{cssxref("border-radius")}} - {{cssxref("border-right")}} - {{cssxref("border-style")}} - {{cssxref("border-top")}} - {{cssxref("border-width")}} - {{cssxref("column-rule")}} - {{cssxref("columns")}} - {{cssxref("container")}} - {{cssxref("contain-intrinsic-size")}} - {{cssxref("flex")}} - {{cssxref("flex-flow")}} - {{cssxref("font")}} - {{cssxref("font-synthesis")}} - {{cssxref("font-variant")}} - {{cssxref("gap")}} - {{cssxref("grid")}} - {{cssxref("grid-area")}} - {{cssxref("grid-column")}} - {{cssxref("grid-row")}} - {{cssxref("grid-template")}} - {{cssxref("inset")}} - {{cssxref("list-style")}} - {{cssxref("margin")}} - {{cssxref("mask")}} - {{cssxref("mask-border")}} - {{cssxref("offset")}} - {{cssxref("outline")}} - {{cssxref("overflow")}} - {{cssxref("padding")}} - {{cssxref("place-content")}} - {{cssxref("place-items")}} - {{cssxref("place-self")}} - {{cssxref("scroll-margin")}} - {{cssxref("scroll-padding")}} - {{cssxref("scroll-timeline")}} - {{cssxref("text-decoration")}} - {{cssxref("text-emphasis")}} - {{cssxref("transition")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_doublecolon_selection/index.md
--- title: "::selection" slug: Web/CSS/::selection page-type: css-pseudo-element browser-compat: css.selectors.selection --- {{CSSRef}} The **`::selection`** CSS [pseudo-element](/en-US/docs/Web/CSS/Pseudo-elements) applies styles to the part of a document that has been highlighted by the user (such as clicking and dragging the mouse across text). {{EmbedInteractiveExample("pages/tabbed/pseudo-element-selection.html", "tabbed-shorter")}} ## Allowable properties Only certain CSS properties can be used with `::selection`: - {{CSSxRef("color")}} - {{CSSxRef("background-color")}} - {{CSSxRef("text-decoration")}} and its associated properties - {{CSSxRef("text-shadow")}} - {{CSSxRef("-webkit-text-stroke-color")}}, {{CSSxRef("-webkit-text-fill-color")}} and {{CSSxRef("-webkit-text-stroke-width")}} In particular, {{CSSxRef("background-image")}} is ignored. ## Syntax ```css ::selection { /* ... */ } ``` ## Examples ### HTML ```html This text has special styles when you highlight it. <p>Also try selecting text in this paragraph.</p> ``` ### CSS ```css hidden ::-moz-selection { color: gold; background-color: red; } p::-moz-selection { color: white; background-color: blue; } ``` ```css /* Make selected text gold on a red background */ ::selection { color: gold; background-color: red; } /* Make selected text in a paragraph white on a blue background */ p::selection { color: white; background-color: blue; } ``` ### Result {{EmbedLiveSample('Examples')}} ## Accessibility concerns **Don't override selected text styles for purely aesthetic reasons** — users can customize them to suit their needs. For people experiencing cognitive concerns or who are less technologically literate, unexpected changes to selection styles may hurt their understanding of the functionality. If overridden, it is important to ensure that the **contrast ratio** between the text and background colors of the selection is high enough that people experiencing low vision conditions can read it. Color contrast ratio is found by comparing the luminosity of the selected text and the selected text background colors. To meet current [Web Content Accessibility Guidelines (WCAG)](https://www.w3.org/WAI/standards-guidelines/wcag/), text content must have a contrast ratio of **4.5:1**, or 3:1 for larger text such as headings. (WCAG defines large text as between `18.66px` and `24px` and [bold](/en-US/docs/Web/CSS/font-weight), or `24px` or larger.) - [WebAIM: Color Contrast Checker](https://webaim.org/resources/contrastchecker/) - [MDN Understanding WCAG, Guideline 1.4 explanations](/en-US/docs/Web/Accessibility/Understanding_WCAG/Perceivable#guideline_1.4_make_it_easier_for_users_to_see_and_hear_content_including_separating_foreground_from_background) - [Understanding Success Criterion 1.4.3 | W3C Understanding WCAG 2.0](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html) ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref("pointer-events")}} - control which events are active on the element
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_colon_-moz-drag-over/index.md
--- title: ":-moz-drag-over" slug: Web/CSS/:-moz-drag-over page-type: css-pseudo-class status: - non-standard browser-compat: css.selectors:-moz-drag-over --- {{CSSRef}}{{Non-standard_header}} The **`:-moz-drag-over`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) is a [Mozilla extension](/en-US/docs/Web/CSS/Mozilla_Extensions) that matches an element when a {{domxref("HTMLElement/dragover_event", "dragover")}} event is called on it. ## Syntax ```css :-moz-drag-over { /* ... */ } ``` ## Examples ### HTML ```html <table border="1"> <tr> <td width="100px" height="100px">Drag Over</td> </tr> </table> ``` ### CSS ```css td:-moz-drag-over { color: red; } ``` ### Result {{EmbedLiveSample("Examples")}} ## Specifications Not part of any standard. ## See also - [Mozilla CSS extensions](/en-US/docs/Web/CSS/Mozilla_Extensions) - [HTML drag and drop](/en-US/docs/Web/API/HTML_Drag_and_Drop_API)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_colon_muted/index.md
--- title: ":muted" slug: Web/CSS/:muted page-type: css-pseudo-class browser-compat: css.selectors.muted --- {{CSSRef}} The **`:muted`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) selector represents an element that is capable of making sound, such as {{htmlelement("audio")}} or {{htmlelement("video")}}, but is muted (forced silent). Muted is different from {{cssxref(":volume-locked")}} in that the page author has control over whether a media element can be muted or un-muted. User agents may set media `muted` value according to use preferences (e.g., remembering the last set value across sessions, on a per-site basis, or otherwise). An element that is `:volume-locked` cannot be muted, un-muted, or have its volume changed via JavaScript because of an operating system or user agent preference. ## Syntax ```css :muted { /* ... */ } ``` ## Examples ### CSS ```css :muted { outline: 5px solid red; } video:muted { outline: 5px solid blue; } ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref(":buffering")}} - {{cssxref(":paused")}} - {{cssxref(":playing")}} - {{cssxref(":seeking")}} - {{cssxref(":stalled")}} - {{cssxref(":volume-locked")}} - [CSS selectors](/en-US/docs/Web/CSS/CSS_selectors) - [`muted`](/en-US/docs/Web/API/HTMLMediaElement/muted) property of {{domxref("HTMLMediaElement")}} objects
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_doublecolon_-moz-range-progress/index.md
--- title: "::-moz-range-progress" slug: Web/CSS/::-moz-range-progress page-type: css-pseudo-element status: - non-standard browser-compat: css.selectors.-moz-range-progress --- {{CSSRef}}{{Non-standard_header}} The **`::-moz-range-progress`** [CSS](/en-US/docs/Web/CSS) [pseudo-element](/en-US/docs/Web/CSS/Pseudo-elements) is a [Mozilla extension](/en-US/docs/Web/CSS/Mozilla_Extensions) that represents the lower portion of the _track_ (i.e., groove) in which the indicator slides in an {{HTMLElement("input")}} of `type="range"`. This portion corresponds to values lower than the value currently selected by the _thumb_ (i.e., virtual knob). > **Note:** Using `::-moz-range-progress` with anything but an `<input type="range">` doesn't match anything and has no effect. ## Syntax ```css ::-moz-range-progress { /* ... */ } ``` ## Examples ### HTML ```html <input type="range" min="0" max="100" step="5" value="50" /> ``` ### CSS ```css input[type="range"]::-moz-range-progress { background-color: green; height: 1em; } ``` ### Result {{EmbedLiveSample("Examples", 300, 50)}} A progress bar using this style might look something like this: ![The progress bar is a thick green square to the left of the thumb and a thin grey line to the right. The thumb is a circle with a diameter the height of the green area.](screen_shot_2015-12-04_at_20.14.48.png) ## Specifications Not part of any standard. ## Browser compatibility {{Compat}} ## See also - The pseudo-elements used by Gecko to style other parts of a range input: - {{cssxref("::-moz-range-thumb")}} represents the indicator that slides in the groove. - {{cssxref("::-moz-range-track")}} represents the groove in which the thumb slides. - [CSS-Tricks: Styling Cross-Browser Compatible Range Inputs with CSS](https://css-tricks.com/styling-cross-browser-compatible-range-inputs-css/) - [QuirksMode: Styling and scripting sliders](https://www.quirksmode.org/blog/archives/2015/11/styling_and_scr.html)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/animation/index.md
--- title: animation slug: Web/CSS/animation page-type: css-shorthand-property browser-compat: css.properties.animation --- {{CSSRef}} The **`animation`** [shorthand](/en-US/docs/Web/CSS/Shorthand_properties) [CSS](/en-US/docs/Web/CSS) property applies an animation between styles. It is a shorthand for {{cssxref("animation-name")}}, {{cssxref("animation-duration")}}, {{cssxref("animation-timing-function")}}, {{cssxref("animation-delay")}}, {{cssxref("animation-iteration-count")}}, {{cssxref("animation-direction")}}, {{cssxref("animation-fill-mode")}}, {{cssxref("animation-play-state")}}, and {{cssxref("animation-timeline")}}. {{EmbedInteractiveExample("pages/css/animation.html")}} ## Constituent properties This property is a shorthand for the following CSS properties: - [`animation-delay`](/en-US/docs/Web/CSS/animation-delay) - [`animation-direction`](/en-US/docs/Web/CSS/animation-direction) - [`animation-duration`](/en-US/docs/Web/CSS/animation-duration) - [`animation-fill-mode`](/en-US/docs/Web/CSS/animation-fill-mode) - [`animation-iteration-count`](/en-US/docs/Web/CSS/animation-iteration-count) - [`animation-name`](/en-US/docs/Web/CSS/animation-name) - [`animation-play-state`](/en-US/docs/Web/CSS/animation-play-state) - [`animation-timeline`](/en-US/docs/Web/CSS/animation-timeline) - [`animation-timing-function`](/en-US/docs/Web/CSS/animation-timing-function) ## Syntax ```css /* @keyframes duration | easing-function | delay | iteration-count | direction | fill-mode | play-state | name */ animation: 3s ease-in 1s 2 reverse both paused slidein; /* @keyframes duration | easing-function | delay | name */ animation: 3s linear 1s slidein; /* two animations */ animation: 3s linear slidein, 3s ease-out 5s slideout; ``` The `animation` property is specified as one or more single animations, separated by commas. Each individual animation is specified as: - zero, one, or two occurrences of the {{cssxref("&lt;time&gt;")}} value - zero or one occurrences of the following values: - {{cssxref("animation", "&lt;single-easing-function&gt;", "#single-easing-function")}} - {{cssxref("animation", "&lt;single-animation-iteration-count&gt;", "#single-animation-iteration-count")}} - {{cssxref("animation", "&lt;single-animation-direction&gt;", "#single-animation-direction")}} - {{cssxref("animation", "&lt;single-animation-fill-mode&gt;", "#single-animation-fill-mode")}} - {{cssxref("animation", "&lt;single-animation-play-state&gt;", "#single-animation-play-state")}} - an optional name for the animation, which may be `none`, a {{cssxref("&lt;custom-ident&gt;")}}, or a {{cssxref("&lt;string&gt;")}} > **Note:** {{cssxref("animation-timeline")}}, {{cssxref("animation-range-start")}}, and {{cssxref("animation-range-end")}} are not currently included in this list, as current implementations are reset-only. This means that including `animation` resets a previously-declared `animation-timeline` value to `auto` and previously-declared `animation-range-start` and `animation-range-end` values to `normal`, but these properties cannot be set via `animation`. When creating [CSS scroll-driven animations](/en-US/docs/Web/CSS/CSS_scroll-driven_animations), you need to declare these properties after declaring any `animation` shorthand for it to take effect. ### Values - `<single-easing-function>` - : Determines the type of transition. The value must be one of those available in {{cssxref("easing-function")}}. - `<single-animation-iteration-count>` - : The number of times the animation is played. The value must be one of those available in {{cssxref("animation-iteration-count")}}. - `<single-animation-direction>` - : The direction in which the animation is played. The value must be one of those available in {{cssxref("animation-direction")}}. - `<single-animation-fill-mode>` - : Determines how styles should be applied to the animation's target before and after its execution. The value must be one of those available in {{cssxref("animation-fill-mode")}}. - `<single-animation-play-state>` - : Determines whether the animation is playing or not. The value must be one of those available in {{cssxref("animation-play-state")}}. ## Description The order of time values within each animation definition is important: the first value that can be parsed as a {{cssxref("&lt;time&gt;")}} is assigned to the {{cssxref("animation-duration")}}, and the second one is assigned to {{cssxref("animation-delay")}}. The order of other values within each animation definition is also important for distinguishing an {{cssxref("animation-name")}} value from other values. If a value in the `animation` shorthand can be parsed as a value for an animation property other than `animation-name`, then the value will be applied to that property first and not to `animation-name`. For this reason, the recommended practice is to specify a value for `animation-name` as the last value in a list of values when using the `animation` shorthand; this holds true even when you specify multiple, comma-separated animations using the `animation` shorthand. While an animation name must be set for an animation to be applied, all values of the `animation` shorthand are optional, and default to the initial value for each long-hand `animation` component. The initial value of `animation-name` is `none`, meaning if no `animation-name` value is declared in the `animation` shorthand property, there is no animation to apply on any of the properties. When the `animation-duration` value is omitted from the `animation` shorthand property, the value for this property defaults to `0s`. In this case, the animation will still occur (the [`animationStart`](/en-US/docs/Web/API/Element/animationstart_event) and [`animationEnd`](/en-US/docs/Web/API/Element/animationend_event) events will be fired) but no animation will be visible. ## Accessibility concerns Blinking and flashing animation can be problematic for people with cognitive concerns such as Attention Deficit Hyperactivity Disorder (ADHD). Additionally, certain kinds of motion can be a trigger for Vestibular disorders, epilepsy, and migraine and Scotopic sensitivity. Consider providing a mechanism for pausing or disabling animation as well as using the [Reduced Motion Media Query](/en-US/docs/Web/CSS/@media/prefers-reduced-motion) to create a complimentary experience for users who have expressed a preference for reduced animated experiences. - [Designing Safer Web Animation For Motion Sensitivity · An A List Apart Article](https://alistapart.com/article/designing-safer-web-animation-for-motion-sensitivity/) - [An Introduction to the Reduced Motion Media Query | CSS-Tricks](https://css-tricks.com/introduction-reduced-motion-media-query/) - [Responsive Design for Motion | WebKit](https://webkit.org/blog/7551/responsive-design-for-motion/) - [MDN Understanding WCAG, Guideline 2.2 explanations](/en-US/docs/Web/Accessibility/Understanding_WCAG/Operable#guideline_2.2_%e2%80%94_enough_time_provide_users_enough_time_to_read_and_use_content) - [Understanding Success Criterion 2.2.2 | W3C Understanding WCAG 2.0](https://www.w3.org/TR/UNDERSTANDING-WCAG20/time-limits-pause.html) ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples > **Note:** Animating [CSS Box Model](/en-US/docs/Web/CSS/CSS_box_model) properties is discouraged. Animating any box model property is inherently CPU intensive; consider animating the [transform](/en-US/docs/Web/CSS/transform) property instead. ### Sun Rise Here we animate a yellow sun across a light blue sky. The sun rises to the center of the viewport and then falls out of sight. ```html <div class="sun"></div> ``` ```css :root { overflow: hidden; /* hides any part of the sun below the horizon */ background-color: lightblue; display: flex; justify-content: center; /* centers the sun in the background */ } .sun { background-color: yellow; border-radius: 50%; /* creates a circular background */ height: 100vh; /* makes the sun the size of the viewport */ aspect-ratio: 1 / 1; animation: 4s linear 0s infinite alternate sun-rise; } @keyframes sun-rise { from { /* pushes the sun down past the viewport */ transform: translateY(110vh); } to { /* returns the sun to its default position */ transform: translateY(0); } } ``` {{EmbedLiveSample('Sun_Rise')}} ### Animating Multiple Properties Adding onto the sun animation in the previous example, we add a second animation changing the color of the sun as it rises and sets. The sun starts off dark red when it is below the horizon and changes to a bright orange as it reaches the top. ```html <div class="sun"></div> ``` ```css :root { overflow: hidden; background-color: lightblue; display: flex; justify-content: center; } .sun { background-color: yellow; border-radius: 50%; height: 100vh; aspect-ratio: 1 / 1; animation: 4s linear 0s infinite alternate animating-multiple-properties; } /* it is possible to animate multiple properties in a single animation */ @keyframes animating-multiple-properties { from { transform: translateY(110vh); background-color: red; filter: brightness(75%); } to { transform: translateY(0); background-color: orange; /* unset properties i.e. 'filter' will revert to default values */ } } ``` {{EmbedLiveSample('Animating Multiple Properties')}} ### Applying Multiple Animations Here is a sun that rises and falls on a lightblue background. The sun gradually rotates through a rainbow of colors. The timing of the sun's position and color are independent. ```html <div class="sun"></div> ``` ```css :root { overflow: hidden; background-color: lightblue; display: flex; justify-content: center; } .sun { background-color: yellow; border-radius: 50%; height: 100vh; aspect-ratio: 1 / 1; /* multiple animations are separated by commas, each animation's parameters are set independently */ animation: 4s linear 0s infinite alternate rise, 24s linear 0s infinite psychedelic; } @keyframes rise { from { transform: translateY(110vh); } to { transform: translateY(0); } } @keyframes psychedelic { from { filter: hue-rotate(0deg); } to { filter: hue-rotate(360deg); } } ``` {{EmbedLiveSample('Applying Multiple Animations')}} ### Cascading Multiple Animations Here is a yellow sun on a lightblue background. The sun bounces between the left and right sides of the viewport. The sun remains in the viewport even though a rise animation is defined. The rise animation's transform property is 'overwritten' by the bounce animation. ```html <div class="sun"></div> ``` ```css :root { overflow: hidden; background-color: lightblue; display: flex; justify-content: center; } .sun { background-color: yellow; border-radius: 50%; height: 100vh; aspect-ratio: 1 / 1; /* animations declared later in the cascade will override the properties of previously declared animations */ /* bounce 'overwrites' the transform set by rise, hence the sun only moves horizontally */ animation: 4s linear 0s infinite alternate rise, 4s linear 0s infinite alternate bounce; } @keyframes rise { from { transform: translateY(110vh); } to { transform: translateY(0); } } @keyframes bounce { from { transform: translateX(-50vw); } to { transform: translateX(50vw); } } ``` {{EmbedLiveSample('Cascading Multiple Animations')}} See [Using CSS animations](/en-US/docs/Web/CSS/CSS_animations/Using_CSS_animations#examples) for additional examples. ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Using CSS animations](/en-US/docs/Web/CSS/CSS_animations/Using_CSS_animations) - JavaScript {{domxref("AnimationEvent")}} API
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/line-break/index.md
--- title: line-break slug: Web/CSS/line-break page-type: css-property browser-compat: css.properties.line-break --- {{CSSRef}} The **`line-break`** CSS property sets how to break lines of Chinese, Japanese, or Korean (CJK) text when working with punctuation and symbols. {{EmbedInteractiveExample("pages/css/line-break.html")}} ## Syntax ```css /* Keyword values */ line-break: auto; line-break: loose; line-break: normal; line-break: strict; line-break: anywhere; /* Global values */ line-break: inherit; line-break: initial; line-break: revert; line-break: revert-layer; line-break: unset; ``` ### Values - `auto` - : Break text using the default line break rule. - `loose` - : Break text using the least restrictive line break rule. Typically used for short lines, such as in newspapers. - `normal` - : Break text using the most common line break rule. - `strict` - : Break text using the most stringent line break rule. - `anywhere` - : There is a soft wrap opportunity around every typographic character unit, including around any punctuation character or preserved white spaces, or in the middle of words, disregarding any prohibition against line breaks, even those introduced by characters with the GL, WJ, or ZWJ character class or mandated by the {{cssxref("word-break")}} property. The different wrapping opportunities must not be prioritized. Hyphenation is not applied. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Setting text wrapping See whether the text is wrapped before "々", "ぁ" and "。". #### HTML ```html <div lang="ja"> <p class="wrapbox auto"> auto:<br />そこは湖のほとりで木々が輝いていた。<br />その景色に、美しいなぁと思わずつぶやいた。 </p> <p class="wrapbox loose"> loose:<br />そこは湖のほとりで木々が輝いていた。<br />その景色に、美しいなぁと思わずつぶやいた。 </p> <p class="wrapbox normal"> normal:<br />そこは湖のほとりで木々が輝いていた。<br />その景色に、美しいなぁと思わずつぶやいた。 </p> <p class="wrapbox strict"> strict:<br />そこは湖のほとりで木々が輝いていた。<br />その景色に、美しいなぁと思わずつぶやいた。 </p> <p class="wrapbox anywhere"> anywhere:<br />そこは湖のほとりで木々が輝いていた。<br />その景色に、美しいなぁと思わずつぶやいた。 </p> </div> ``` #### CSS ```css .wrapbox { width: 10em; margin: 0.5em; white-space: normal; vertical-align: top; display: inline-block; } .auto { line-break: auto; } .loose { line-break: loose; } .normal { line-break: normal; } .strict { line-break: strict; } .anywhere { line-break: anywhere; } ``` #### Result {{ EmbedLiveSample('Setting_text_wrapping', 200, 400) }} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} - [CSS and International text](https://www.w3.org/International/articles/css3-text/)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/frequency-percentage/index.md
--- title: <frequency-percentage> slug: Web/CSS/frequency-percentage page-type: css-type browser-compat: css.types.frequency-percentage --- {{CSSRef}} The **`<frequency-percentage>`** [CSS](/en-US/docs/Web/CSS) [data type](/en-US/docs/Web/CSS/CSS_Types) represents a value that can be either a {{Cssxref("frequency")}} or a {{Cssxref("percentage")}}. Frequency values, e.g. the pitch of a speaking voice, are not currently used in any CSS properties. ## Syntax The value of a `<frequency-percentage>` is either a {{Cssxref("frequency")}} or a {{Cssxref("percentage")}}; see their individual reference pages for details about their syntaxes. ## Description ### Use in calc() Where a `<frequency-percentage>` is specified as an allowable type, this means that the percentage resolves to a frequency and therefore can be used in a [`calc()`](/en-US/docs/Web/CSS/calc) expression. ## Formal syntax {{csssyntax}} ## Examples ### Valid percentage values ```plain example-good 90% Positive percentage +90% Positive percentage with leading + -90% Negative percentage — not valid for all properties that use percentages ``` ### Invalid percentage values ```plain example-bad 90 % No space is allowed between the number and the unit ``` ### Valid frequency values ```plain example-good 12Hz Positive integer 4.3Hz Non-integer 14KhZ The unit is case-insensitive, though non-SI capitalization is not recommended. +0Hz Zero, with a leading + and a unit -0kHz Zero, with a leading - and a unit ``` ### Invalid frequency values ```plain example-bad 12.0 This is a <number>, not an <frequency>, because it is missing a unit. 7 Hz No space is allowed between the number and the unit. 0 Although unitless zero is an allowable <length>, it's an invalid <frequency>. ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS data types](/en-US/docs/Web/CSS/CSS_Types) - [CSS Values and Units](/en-US/docs/Web/CSS/CSS_Values_and_Units) - Related CSS data types: - {{cssxref("frequency", "&lt;frequency&gt;")}} - {{cssxref("percentage", "&lt;percentage&gt;")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/paint-order/index.md
--- title: paint-order slug: Web/CSS/paint-order page-type: css-property browser-compat: css.properties.paint-order --- {{CSSRef}} The **`paint-order`** [CSS](/en-US/docs/Web/CSS) property lets you control the order in which the fill and stroke (and painting markers) of text content and shapes are drawn. ## Syntax ```css /* Normal */ paint-order: normal; /* Single values */ paint-order: stroke; /* draw the stroke first, then fill and markers */ paint-order: markers; /* draw the markers first, then fill and stroke */ /* Multiple values */ paint-order: stroke fill; /* draw the stroke first, then the fill, then the markers */ paint-order: markers stroke fill; /* draw markers, then stroke, then fill */ /* Global values */ paint-order: inherit; paint-order: initial; paint-order: revert; paint-order: revert-layer; paint-order: unset; ``` If no value is specified, the default paint order is `fill`, `stroke`, `markers`. When one value is specified, that one is painted first, followed by the other two in their default order relative to one another. When two values are specified, they will be painted in the order they are specified in, followed by the unspecified one. > **Note:** In the case of this property, markers are only appropriate when drawing SVG shapes involving the use of the `marker-*` properties (e.g. [`marker-start`](/en-US/docs/Web/SVG/Attribute/marker-start)) and [`<marker>`](/en-US/docs/Web/SVG/Element/marker) element. They do not apply to HTML text, so in that case, you can only determine the order of `stroke` and `fill`. ### Values - `normal` - : Paint the different items in normal paint order. - `stroke`, `fill`, `markers` - : Specify some or all of these values in the order you want them to be painted in. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Reversing the paint order of stroke and fill #### SVG ```html <svg xmlns="http://www.w3.org/2000/svg" width="400" height="200"> <text x="10" y="75">stroke in front</text> <text x="10" y="150" class="stroke-behind">stroke behind</text> </svg> ``` #### CSS ```css text { font-family: sans-serif; font-size: 50px; font-weight: bold; fill: black; stroke: red; stroke-width: 4px; } .stroke-behind { paint-order: stroke fill; } ``` #### Result {{EmbedLiveSample("Reversing_the_paint_order_of_stroke_and_fill", "100%", 165)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS Tricks: paint-order](https://css-tricks.com/almanac/properties/p/paint-order/)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/mask-position/index.md
--- title: mask-position slug: Web/CSS/mask-position page-type: css-property browser-compat: css.properties.mask-position --- {{CSSRef}} The **`mask-position`** [CSS](/en-US/docs/Web/CSS) property sets the initial position, relative to the mask position layer set by {{cssxref("mask-origin")}}, for each defined mask image. ## Syntax ```css /* Keyword values */ mask-position: top; mask-position: bottom; mask-position: left; mask-position: right; mask-position: center; /* <position> values */ mask-position: 25% 75%; mask-position: 0px 0px; mask-position: 10% 8em; /* Multiple values */ mask-position: top right; mask-position: 1rem 1rem, center; /* Global values */ mask-position: inherit; mask-position: initial; mask-position: revert; mask-position: revert-layer; mask-position: unset; ``` One or more `<position>` values, separated by commas. ### Values - {{cssxref("&lt;position&gt;")}} - : One to four values representing a 2D position regarding the edges of the element's box. Relative or absolute offsets can be given. Note that the position can be set outside of the element's box. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Setting mask position Change the `mask-position` value to any of the allowed values detailed above. If viewing the example in a Chromium-based browser change the value of `-webkit-mask-position`. {{EmbedGHLiveSample("css-examples/masking/mask-position.html", '100%', 760)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Clipping and Masking in CSS](https://css-tricks.com/clipping-masking-css/)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/box-decoration-break/index.md
--- title: box-decoration-break slug: Web/CSS/box-decoration-break page-type: css-property browser-compat: css.properties.box-decoration-break --- {{CSSRef}} The **`box-decoration-break`** [CSS](/en-US/docs/Web/CSS) property specifies how an element's [fragments](/en-US/docs/Web/CSS/CSS_fragmentation) should be rendered when broken across multiple lines, columns, or pages. {{EmbedInteractiveExample("pages/css/box-decoration-break.html")}} The specified value will impact the appearance of the following properties: - {{Cssxref("background")}} - {{Cssxref("border")}} - {{Cssxref("border-image")}} - {{Cssxref("box-shadow")}} - {{Cssxref("clip-path")}} - {{Cssxref("margin")}} - {{Cssxref("padding")}} ## Syntax ```css /* Keyword values */ box-decoration-break: slice; box-decoration-break: clone; /* Global values */ box-decoration-break: inherit; box-decoration-break: initial; box-decoration-break: revert; box-decoration-break: revert-layer; box-decoration-break: unset; ``` The `box-decoration-break` property is specified as one of the keyword values listed below. ### Values - `slice` - : The element is initially rendered as if its box were not fragmented, after which the rendering for this hypothetical box is sliced into pieces for each line/column/page. Note that the hypothetical box can be different for each fragment since it uses its own height if the break occurs in the inline direction, and its own width if the break occurs in the block direction. See the CSS specification for details. - `clone` - : Each box fragment is rendered independently with the specified border, padding, and margin wrapping each fragment. The {{ Cssxref("border-radius") }}, {{ Cssxref("border-image") }}, and {{ Cssxref("box-shadow") }} are applied to each fragment independently. The background is also drawn independently for each fragment, which means that a background image with {{ Cssxref("background-repeat") }}`: no-repeat` may nevertheless repeat multiple times. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Inline box fragments An inline element that contains line breaks styled with: ```html <style> .example { background: linear-gradient(to bottom right, yellow, green); box-shadow: 8px 8px 10px 0px deeppink, -5px -5px 5px 0px blue, 5px 5px 15px 0px yellow; padding: 0em 1em; border-radius: 16px; border-style: solid; margin-left: 10px; font: 24px sans-serif; line-height: 2; } </style> … <span class="example">The<br />quick<br />orange fox</span> ``` This results in: ![A screenshot of the rendering of an inline element styled with box-decoration-break:slice and styles given in the example.](box-decoration-break-inline-slice.png) Adding `box-decoration-break: clone` to the above styles: ```css -webkit-box-decoration-break: clone; box-decoration-break: clone; ``` This one results in: ![A screenshot of the rendering of an inline element styled with box-decoration-break:clone and styles given in the example](box-decoration-break-inline-clone.png) You can [try the two inline examples above](https://mdn.dev/archives/media/attachments/2014/07/12/8179/df096e9eb57177d8b7fdcd0c8f64ef18/box-decoration-break-inline.html) in your browser. Here's an example of an inline element using a large `border-radius` value. The second `"iM"` has a line-break between the `"i"` and the `"M"`. For comparison, the first `"iM"` is without line breaks. Note that if you stack the rendering of the two fragments horizontally next to each other it will result in the non-fragmented rendering. ![A screenshot of the rendering of the second inline element example.](box-decoration-break-slice-inline-2.png) [Try the above example](https://mdn.dev/archives/media/attachments/2014/07/12/8191/7a067e5731355081e856ea02b978ea2e/box-decoration-break-inline-extreme.html) in your browser. ### Block box fragments A block element with similar styles as above and no fragmentation results in: ![A screenshot of the rendering of the block element used in the examples without any fragmentation.](box-decoration-break-block.png) Fragmenting the above block into three columns results in: ![A screenshot of the rendering of the fragmented block used in the examples styled with box-decoration-break:slice.](box-decoration-break-block-slice.png) Note that stacking these pieces vertically will result in the non-fragmented rendering. Now, the same example but styled with `box-decoration-break: clone` results in: ![A screenshot of the rendering of the fragmented block used in the examples styled with box-decoration-break:clone.](box-decoration-break-block-clone.png) Note here that each fragment has an identical replicated border, box-shadow, and background. You can [try the block examples above](https://mdn.dev/archives/media/attachments/2014/07/12/8187/6288bde9d276d78e203c9f8b9a26ff65/box-decoration-break-block.html) in your browser. ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref("break-after")}}, {{cssxref("break-before")}}, {{cssxref("break-inside")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/unset/index.md
--- title: unset slug: Web/CSS/unset page-type: css-keyword browser-compat: css.types.global_keywords.unset --- {{CSSRef}} The **`unset`** CSS keyword resets a property to its inherited value if the property naturally inherits from its parent, and to its [initial value](/en-US/docs/Web/CSS/initial_value) if not. In other words, it behaves like the {{cssxref("inherit")}} keyword in the first case, when the property is an [inherited property](/en-US/docs/Web/CSS/Inheritance#inherited_properties), and like the {{cssxref("initial")}} keyword in the second case, when the property is a [non-inherited property](/en-US/docs/Web/CSS/Inheritance#non-inherited_properties). **`unset`** can be applied to any CSS property, including the CSS shorthand property {{cssxref("all")}}. ## Examples ### Color [`color`](/en-US/docs/Web/CSS/color#formal_definition) is an inherited property. #### HTML ```html <p>This text is red.</p> <div class="foo"> <p>This text is also red.</p> </div> <div class="bar"> <p>This text is green (default inherited value).</p> </div> ``` #### CSS ```css .foo { color: blue; } .bar { color: green; } p { color: red; } .bar p { color: unset; } ``` #### Result {{ EmbedLiveSample('Color') }} ### Border [`border`](/en-US/docs/Web/CSS/border#formal_definition) is a non-inherited property. #### HTML ```html <p>This text has a red border.</p> <div> <p>This text has a red border.</p> </div> <div class="bar"> <p>This text has a black border (initial default, not inherited).</p> </div> ``` #### CSS ```css div { border: 1px solid green; } p { border: 1px solid red; } .bar p { border-color: unset; } ``` #### Result {{ EmbedLiveSample('Border', 'auto', 200) }} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - Use the {{cssxref("initial")}} keyword to set a property to its initial value. - Use the {{cssxref("inherit")}} keyword to make an element's property the same as its parent. - Use the {{cssxref("revert")}} keyword to reset a property to the value established by the user-agent stylesheet (or by user styles, if any exist). - Use the {{cssxref("revert-layer")}} keyword to reset a property to the value established in a previous cascade layer. - The {{cssxref("all")}} property lets you reset all properties to their initial, inherited, reverted, or unset state at once.
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/transition-property/index.md
--- title: transition-property slug: Web/CSS/transition-property page-type: css-property browser-compat: css.properties.transition-property --- {{CSSRef}} The **`transition-property`** [CSS](/en-US/docs/Web/CSS) property sets the CSS properties to which a [transition effect](/en-US/docs/Web/CSS/CSS_transitions/Using_CSS_transitions) should be applied. {{EmbedInteractiveExample("pages/css/transition-property.html")}} If you specify a shorthand property (e.g., {{cssxref("background")}}), all of its longhand sub-properties that can be animated will be. ## Syntax ```css /* Keyword values */ transition-property: none; transition-property: all; /* <custom-ident> values */ transition-property: test_05; transition-property: -specific; transition-property: sliding-vertically; /* Multiple values */ transition-property: test1, animation4; transition-property: all, height, color; transition-property: all, -moz-specific, sliding; /* Global values */ transition-property: inherit; transition-property: initial; transition-property: revert; transition-property: revert-layer; transition-property: unset; ``` ### Values - `none` - : No properties will transition. - `all` - : All properties that can transition will. - {{cssxref("&lt;custom-ident&gt;")}} - : A string identifying the property to which a transition effect should be applied when its value changes. ## Formal definition {{CSSInfo}} ## Formal syntax {{csssyntax}} ## Examples ### Basic example When the button is hovered or focused, it undergoes a one-second color transition; the `transition-property` is [`background-color`](/en-US/docs/Web/CSS/background-color). #### HTML ```html <button class="target">Focus me!</button> ``` #### CSS ```css hidden html { height: 100vh; } button { font-size: 1.4rem; padding: 10px 20px; border: 1px solid #ccc; border-radius: 10px; outline: none; } ``` ```css .target { transition-property: background-color; transition-duration: 1s; background-color: #ccc; } .target:hover, .target:focus { background-color: #eee; } ``` {{EmbedLiveSample('Basic_example', 600, 100)}} See our [Using CSS transitions](/en-US/docs/Web/CSS/CSS_transitions/Using_CSS_transitions) guide for more `transition-property` examples. ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Using CSS transitions](/en-US/docs/Web/CSS/CSS_transitions/Using_CSS_transitions) - {{cssxref('transition')}} - {{cssxref('transition-duration')}} - {{cssxref('transition-timing-function')}} - {{cssxref('transition-delay')}} - {{domxref("TransitionEvent")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/time/index.md
--- title: <time> slug: Web/CSS/time page-type: css-type browser-compat: css.types.time --- {{CSSRef}} The **`<time>`** [CSS](/en-US/docs/Web/CSS) [data type](/en-US/docs/Web/CSS/CSS_Types) represents a time value expressed in seconds or milliseconds. It is used in {{cssxref("animation")}}, {{cssxref("transition")}}, and related properties. ## Syntax The `<time>` data type consists of a {{cssxref("&lt;number&gt;")}} followed by one of the units listed below. Optionally, it may be preceded by a single `+` or `-` sign. As with all dimensions, there is no space between the unit literal and the number. > **Note:** Although the number `0` is always the same regardless of unit, the unit may not be omitted. In other words, `0` is invalid and does not represent `0s` or `0ms`. ### Units - `s` - : Represents a time in seconds. Examples: `0s`, `1.5s`, `-60s`. - `ms` - : Represents a time in milliseconds. Examples: `0ms`, `150.25ms`, `-60000ms`. > **Note:** Conversion between `s` and `ms` follows the logical `1s` = `1000ms`. ## Examples ### Valid times ```plain example-good 12s Positive integer -456ms Negative integer 4.3ms Non-integer 14mS The unit is case-insensitive, although capital letters are not recommended. +0s Zero with a leading + and a unit -0ms Zero with a leading - and a unit ``` ### Invalid times ```plain example-bad 0 Although unitless zero is allowed for <length>s, it's invalid for <time>s. 12.0 This is a <number>, not a <time>, because it's missing a unit. 7 ms No space is allowed between the number and the unit. ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref("&lt;time-percentage&gt;")}} - [CSS Values and Units](/en-US/docs/Web/CSS/CSS_Values_and_Units)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/text-wrap/index.md
--- title: text-wrap slug: Web/CSS/text-wrap page-type: css-property browser-compat: css.properties.text-wrap --- {{CSSRef}} The **`text-wrap`** CSS property controls how text inside an element is wrapped. The different values provide: - Typographic improvements, for example more balanced line lengths across broken headings - A way to turn text wrapping off completely. > **Note:** The {{CSSxRef("white-space-collapse")}} and `text-wrap` properties can be declared together using the {{CSSxRef("white-space")}} shorthand property. ## Syntax ```css /* Keyword values */ text-wrap: wrap; text-wrap: nowrap; text-wrap: balance; text-wrap: pretty; text-wrap: stable; /* Global values */ text-wrap: inherit; text-wrap: initial; text-wrap: revert; text-wrap: revert-layer; text-wrap: unset; ``` The `text-wrap` property is specified as a single keyword chosen from the list of values below. ### Values - `wrap` - : Text is wrapped across lines at appropriate characters (for example spaces, in languages like English that use space separators) to minimize overflow. This is the default value. - `nowrap` - : Text does not wrap across lines. It will overflow its containing element rather than breaking onto a new line. - `balance` - : Text is wrapped in a way that best balances the number of characters on each line, enhancing layout quality and legibility. Because counting characters and balancing them across multiple lines is computationally expensive, this value is only supported for blocks of text spanning a limited number of lines (six or less for Chromium and ten or less for Firefox). - `pretty` - : Results in the same behavior as `wrap`, except that the user agent will use a slower algorithm that favors better layout over speed. This is intended for body copy where good typography is favored over performance (for example, when the number of [orphans](/en-US/docs/Web/CSS/orphans) should be kept to a minimum). - `stable` {{experimental_inline}} - : Results in the same behavior as `wrap`, except that when the user is editing the content, the lines that come before the lines they are editing remain static rather than the whole block of text re-wrapping. ## Description There are 2 ways that text can flow across lines within a block of content, such as a paragraph ({{HTMLElement("p")}}) or headings ({{HTMLElement("heading_elements","&lt;h1&gt;–&lt;h6&gt;")}}). These are _forced line breaks_, that are controlled by the user, and _soft line breaks_, that are controlled by the browser. The `text-wrap` property can be used to prompt the browser how to control the _soft line breaks_. The value you choose, for `text-wrap`, depends on how many lines of text you anticipate styling, whether the text is `contenteditable`, and whether you need to prioritize appearance or performance. When the styled content will be limited to a short number of lines, such as headings, captions, and blockquotes, `text-wrap: balance` can be added to balance the number of characters on each line, enhancing layout quality and legibility. As browsers limit the number of lines impacted by this property, this value's impact on performance is negligible. For longer sections of text, `text-wrap: pretty` can be used. Note that `pretty` has a negative effect on performance, so it should be only used for longer blocks of text when the layout is more important than speed. The `stable` value improves user experience when used on content that is [`contenteditable`](/en-US/docs/Web/HTML/Global_attributes/contenteditable). This value ensures that, as the user is editing text, the previous lines in the area being edited remain stable. ## Formal definition {{CSSInfo}} ## Formal syntax {{CSSSyntax}} ## Examples ### Basic text wrap value comparison #### HTML ```html <h2 class="wrap" contenteditable="true"> The default behavior; the text in the heading wraps "normally" </h2> <h2 class="nowrap" contenteditable="true"> In this case the text in the heading doesn't wrap, and overflows the container </h2> <h2 class="balance" contenteditable="true"> In this case the text in the heading is nicely balanced across lines </h2> ``` ### CSS ```css .wrap { text-wrap: wrap; } .nowrap { text-wrap: nowrap; } .balance { text-wrap: balance; } h2 { font-size: 2rem; font-family: sans-serif; } ``` #### Result The text in the example is editable. Change the text, adding long words, to view how the different line and word lengths impact wrapping. {{EmbedLiveSample("Examples", "100%", 350)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{CSSxRef("white-space")}} - {{CSSxRef("white-space-collapse")}} - [CSS text module](/en-US/docs/Web/CSS/CSS_text) - [CSS `text-wrap: balance`](https://developer.chrome.com/blog/css-text-wrap-balance/) on developer.chrome.com - [CSS `text-wrap: pretty`](https://developer.chrome.com/blog/css-text-wrap-pretty/) on developer.chrome.com
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/caption-side/index.md
--- title: caption-side slug: Web/CSS/caption-side page-type: css-property browser-compat: css.properties.caption-side --- {{CSSRef}} The **`caption-side`** [CSS](/en-US/docs/Web/CSS) property puts the content of a table's {{HTMLElement("caption")}} on the specified side. The values are relative to the {{cssxref('writing-mode')}} of the table. {{EmbedInteractiveExample("pages/css/caption-side.html")}} ## Syntax ```css /* Directional values */ caption-side: top; caption-side: bottom; /* Logical values */ caption-side: block-start; caption-side: block-end; caption-side: inline-start; caption-side: inline-end; /* Global values */ caption-side: inherit; caption-side: initial; caption-side: revert; caption-side: revert-layer; caption-side: unset; ``` The `caption-side` property is specified as one of the keyword values listed below. ### Values - `top` - : The caption box should be positioned above the table. - `bottom` - : The caption box should be positioned below the table. - `block-start` - : The caption box should be positioned at the block start edge of the table. - `block-end` - : The caption box should be positioned at the block end edge of the table. - `inline-start` - : The caption box should be positioned at the inline start edge of the table. - `inline-end` - : The caption box should be positioned at the inline end edge of the table. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Setting captions above and below #### HTML ```html <table class="top"> <caption> Caption ABOVE the table </caption> <tr> <td>Some data</td> <td>Some more data</td> </tr> </table> <br /> <table class="bottom"> <caption> Caption BELOW the table </caption> <tr> <td>Some data</td> <td>Some more data</td> </tr> </table> ``` #### CSS ```css .top caption { caption-side: top; } .bottom caption { caption-side: bottom; } table { border: 1px solid red; } td { border: 1px solid blue; } ``` #### Result {{EmbedLiveSample('Setting_captions_above_and_below', 'auto', 160)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_colon_nth-child/index.md
--- title: ":nth-child()" slug: Web/CSS/:nth-child page-type: css-pseudo-class browser-compat: css.selectors.nth-child --- {{CSSRef}} The **`:nth-child()`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) matches elements based on the indexes of the elements in the child list of their parents. In other words, the `:nth-child()` selector selects child elements according to their position among all the sibling elements within a parent element. {{EmbedInteractiveExample("pages/tabbed/pseudo-class-nth-child.html", "tabbed-shorter")}} > **Note:** In the `element:nth-child()` syntax, the child count includes sibling children of any element type; but it is considered a match only if the element _at that child position_ matches the other components of the selector. ## Syntax `:nth-child()` takes a single argument that describes a pattern for matching element indices in a list of siblings. Element indices are 1-based. ```css-nolint :nth-child(<nth> [of <complex-selector-list>]?) { /* ... */ } ``` ### Keyword values - `odd` - : Represents elements whose numeric position in a series of siblings is odd: 1, 3, 5, etc. - `even` - : Represents elements whose numeric position in a series of siblings is even: 2, 4, 6, etc. ### Functional notation - `<An+B>` - : Represents elements whose numeric position in a series of siblings matches the pattern `An+B`, for every positive integer or zero value of `n`, where: - `A` is an integer step size, - `B` is an integer offset, - `n` is all nonnegative integers, starting from 0. It can be read as the `An+B`-th element of a list. The `A` and `B` must both have {{cssxref("&lt;integer&gt;")}} values. ### The `of <selector>` syntax By passing a selector argument, we can select the **nth** element that matches that selector. For example, the following selector matches the first three list items which have a `class="important"` set. ```css :nth-child(-n + 3 of li.important) { } ``` This is different from moving the selector outside of the function, like: ```css li.important:nth-child(-n + 3) { } ``` This selector selects list items if they are among the first three children and match the selector `li.important`. ## Examples ### Example selectors - `tr:nth-child(odd)` or `tr:nth-child(2n+1)` - : Represents the odd rows of an HTML table: 1, 3, 5, etc. - `tr:nth-child(even)` or `tr:nth-child(2n)` - : Represents the even rows of an HTML table: 2, 4, 6, etc. - `:nth-child(7)` - : Represents the seventh element. - `:nth-child(5n)` - : Represents elements **5** \[=5×1], **10** \[=5×2], **15** \[=5×3], **etc.** The first one to be returned as a result of the formula is **0** \[=5x0], resulting in a no-match, since the elements are indexed from 1, whereas `n` starts from 0. This may seem weird at first, but it makes more sense when the `B` part of the formula is `>0`, like in the next example. - `:nth-child(n+7)` - : Represents the seventh and all following elements: **7** \[=0+7], **8** \[=1+7], **9** \[=2+7], **etc.** - `:nth-child(3n+4)` - : Represents elements **4** \[=(3×0)+4], **7** \[=(3×1)+4], **10** \[=(3×2)+4], **13** \[=(3×3)+4], **etc.** - `:nth-child(-n+3)` - : Represents the first three elements. \[=-0+3, -1+3, -2+3] - `p:nth-child(n)` - : Represents every `<p>` element in a group of siblings. This selects the same elements as a simple `p` selector (although with a higher specificity). - `p:nth-child(1)` or `p:nth-child(0n+1)` - : Represents every `<p>` that is the first element in a group of siblings. This is the same as the {{cssxref(":first-child")}} selector (and has the same specificity). - `p:nth-child(n+8):nth-child(-n+15)` - : Represents the eighth through the fifteenth `<p>` elements of a group of siblings. ### Detailed example #### HTML ```html <h3> <code>span:nth-child(2n+1)</code>, WITHOUT an <code>&lt;em&gt;</code> among the child elements. </h3> <p>Children 1, 3, 5, and 7 are selected.</p> <div class="first"> <span>Span 1!</span> <span>Span 2</span> <span>Span 3!</span> <span>Span 4</span> <span>Span 5!</span> <span>Span 6</span> <span>Span 7!</span> </div> <br /> <h3> <code>span:nth-child(2n+1)</code>, WITH an <code>&lt;em&gt;</code> among the child elements. </h3> <p> Children 1, 5, and 7 are selected.<br /> 3 is used in the counting because it is a child, but it isn't selected because it isn't a <code>&lt;span&gt;</code>. </p> <div class="second"> <span>Span!</span> <span>Span</span> <em>This is an `em`.</em> <span>Span</span> <span>Span!</span> <span>Span</span> <span>Span!</span> <span>Span</span> </div> <br /> <h3> <code>span:nth-of-type(2n+1)</code>, WITH an <code>&lt;em&gt;</code> among the child elements. </h3> <p> Children 1, 4, 6, and 8 are selected.<br /> 3 isn't used in the counting or selected because it is an <code>&lt;em&gt;</code>, not a <code>&lt;span&gt;</code>, and <code>nth-of-type</code> only selects children of that type. The <code>&lt;em&gt;</code> is completely skipped over and ignored. </p> <div class="third"> <span>Span!</span> <span>Span</span> <em>This is an `em`.</em> <span>Span!</span> <span>Span</span> <span>Span!</span> <span>Span</span> <span>Span!</span> </div> ``` #### CSS ```css hidden * { font-family: sans-serif; } span, div em { padding: 5px; border: 1px solid tomato; display: inline-block; margin-bottom: 3px; } ``` ```css .first span:nth-child(2n + 1), .second span:nth-child(2n + 1), .third span:nth-of-type(2n + 1) { background-color: tomato; } ``` #### Result {{EmbedLiveSample('Detailed_example', 550, 550)}} ### Using 'of &lt;selector&gt;' In this example there is an unordered list of names, some of them have been marked as **noted** using `class="noted"`. These have been highlighted with a thick bottom border. #### HTML ```html <ul> <li class="noted">Diego</li> <li>Shilpa</li> <li class="noted">Caterina</li> <li>Jayla</li> <li>Tyrone</li> <li>Ricardo</li> <li class="noted">Gila</li> <li>Sienna</li> <li>Titilayo</li> <li class="noted">Lexi</li> <li>Aylin</li> <li>Leo</li> <li>Leyla</li> <li class="noted">Bruce</li> <li>Aisha</li> <li>Veronica</li> <li class="noted">Kyouko</li> <li>Shireen</li> <li>Tanya</li> <li class="noted">Marlene</li> </ul> ``` #### CSS ```css hidden * { font-family: sans-serif; } ul { display: flex; flex-wrap: wrap; list-style: none; font-size: 1.2rem; padding-left: 0; } li { margin: 0.125rem; padding: 0.25rem; } li { border: 1px solid tomato; } .noted { border-bottom: 5px solid tomato; } ``` In the following CSS we are targeting the **even** list items that are marked with `class="noted"`. ```css li:nth-child(even of .noted) { background-color: tomato; border-bottom-color: seagreen; } ``` #### Result Items with `class="noted"` have a thick bottom border and items 3, 10 and 17 have a solid background as they are the _even_ list items with `class="noted"`. {{EmbedLiveSample('of_selector_syntax_example', 550, 120)}} ### of selector syntax vs selector nth-child In this example, there are two unordered lists of names. The first list shows the effect of `li:nth-child(-n + 3 of .noted)` and the second list shows the effect of `li.noted:nth-child(-n + 3)`. #### HTML ```html <ul class="one"> <li class="noted">Diego</li> <li>Shilpa</li> <li class="noted">Caterina</li> <li>Jayla</li> <li>Tyrone</li> <li>Ricardo</li> <li class="noted">Gila</li> <li>Sienna</li> <li>Titilayo</li> <li class="noted">Lexi</li> </ul> <ul class="two"> <li class="noted">Diego</li> <li>Shilpa</li> <li class="noted">Caterina</li> <li>Jayla</li> <li>Tyrone</li> <li>Ricardo</li> <li class="noted">Gila</li> <li>Sienna</li> <li>Titilayo</li> <li class="noted">Lexi</li> </ul> ``` #### CSS ```css hidden * { font-family: sans-serif; } ul { display: flex; flex-wrap: wrap; list-style: none; font-size: 1.2rem; padding-left: 0; } li { margin: 0.125rem; padding: 0.25rem; } li { border: 1px solid tomato; } .noted { border-bottom: 5px solid tomato; } ``` ```css ul.one > li:nth-child(-n + 3 of .noted) { background-color: tomato; border-bottom-color: seagreen; } ul.two > li.noted:nth-child(-n + 3) { background-color: tomato; border-bottom-color: seagreen; } ``` #### Result The first case applies a style to the first three list items with `class="noted"` whether or not they are the first three items in the list. The second case applies a style to the items with `class="noted"` if they are within the first 3 items in the list. {{EmbedLiveSample('of_selector_syntax_vs_selector_nth-child', 550, 150)}} ### Using of selector to fix striped tables A common practice for tables is to use _zebra-stripes_ which alternates between light and dark background colors for rows, making tables easier to read and more accessible. If a row is hidden, the stripes will appear merged and alter the desired effect. In this example, you can see two tables with a `hidden` row. The second table handles hidden rows using `of :not([hidden])`. #### HTML ```html-nolint hidden <div class="wrapper"> ``` ```html-nolint <table class="broken"> <thead> <tr><th>Name</th><th>Age</th><th>Country</th></tr> </thead> <tbody> <tr><td>Mamitiana</td><td>23</td><td>Madagascar</td></tr> <tr><td>Yuki</td><td>48</td><td>Japan</td></tr> <tr hidden><td>Tlayolotl</td><td>36</td><td>Mexico</td></tr> <tr><td>Adilah</td><td>27</td><td>Morocco</td></tr> <tr><td>Vieno</td><td>55</td><td>Finland</td></tr> <tr><td>Ricardo</td><td>66</td><td>Brazil</td></tr> </tbody> </table> <table class="fixed"> <thead> <tr><th>Name</th><th>Age</th><th>Country</th></tr> </thead> <tbody> <tr><td>Mamitiana</td><td>23</td><td>Madagascar</td></tr> <tr><td>Yuki</td><td>48</td><td>Japan</td></tr> <tr hidden><td>Tlayolotl</td><td>36</td><td>Mexico</td></tr> <tr><td>Adilah</td><td>27</td><td>Morocco</td></tr> <tr><td>Vieno</td><td>55</td><td>Finland</td></tr> <tr><td>Ricardo</td><td>66</td><td>Brazil</td></tr> </tbody> </table> ``` ```html hidden </div> ``` #### CSS ```css hidden .wrapper { display: flex; justify-content: space-around; } td { padding: 0.125rem 0.5rem; } ``` ```css .broken > tbody > tr:nth-child(even) { background-color: silver; } ``` ```css .fixed > tbody > tr:nth-child(even of :not([hidden])) { background-color: silver; } ``` #### Result In the first table this is just using `:nth-child(even)` the third row has the `hidden` attribute applied to it. So in this instance the 3rd row is not visible and the 2nd & 4th rows are counted as even, which technically they are but visually they are not. In the second table the _of syntax_ is used to target only the `tr`s that are **not** hidden using `:nth-child(even of :not([hidden]))`. {{EmbedLiveSample('Using_of_selector_to_fix_striped_tables', 550, 180)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{ Cssxref(":nth-of-type", ":nth-of-type()") }} - {{ Cssxref(":nth-last-child", ":nth-last-child()") }} - {{ Cssxref(":has", ":has()") }}: pseudo-class for selecting parent element - [Tree-structural pseudo-classes](/en-US/docs/Web/CSS/Pseudo-classes#tree-structural_pseudo-classes) - [CSS selectors](/en-US/docs/Web/CSS/CSS_selectors) module
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/scroll-margin-top/index.md
--- title: scroll-margin-top slug: Web/CSS/scroll-margin-top page-type: css-property browser-compat: css.properties.scroll-margin-top --- {{CSSRef}} The `scroll-margin-top` property defines the top margin of the scroll snap area that is used for snapping this box to the snapport. The scroll snap area is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the scroll container's coordinate space), then adding the specified outsets. {{EmbedInteractiveExample("pages/css/scroll-margin-top.html")}} ## Syntax ```css /* <length> values */ scroll-margin-top: 10px; scroll-margin-top: 1em; /* Global values */ scroll-margin-top: inherit; scroll-margin-top: initial; scroll-margin-top: revert; scroll-margin-top: revert-layer; scroll-margin-top: unset; ``` ### Values - {{CSSXref("&lt;length&gt;")}} - : An outset from the top edge of the scroll container. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS scroll snap](/en-US/docs/Web/CSS/CSS_scroll_snap) - [Well-controlled scrolling with CSS scroll snap](https://web.dev/articles/css-scroll-snap)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_colon_past/index.md
--- title: ":past" slug: Web/CSS/:past page-type: css-pseudo-class browser-compat: css.selectors.past --- {{CSSRef}} The **`:past`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) selector is a time-dimensional pseudo-class that will match for any element which appears entirely before an element that matches {{cssxref(":current")}}. For example in a video with captions which are being displayed by [WebVTT](/en-US/docs/Web/API/WebVTT_API). ```css :past(p, span) { display: none; } ``` ## Syntax ```css :past { /* ... */ } ``` ## Examples ### CSS ```css :past(p, span) { display: none; } ``` ### HTML ```html <video controls preload="metadata"> <source src="video.mp4" type="video/mp4" /> <source src="video.webm" type="video/webm" /> <track label="English" kind="subtitles" srclang="en" src="subtitles.vtt" default /> </video> ``` ### WebVTT ```plain WEBVTT FILE 1 00:00:03.500 --> 00:00:05.000 This is the first caption 2 00:00:06.000 --> 00:00:09.000 This is the second caption 3 00:00:11.000 --> 00:00:19.000 This is the third caption ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Web Video Text Tracks Format (WebVTT)](/en-US/docs/Web/API/WebVTT_API) - {{cssxref(":current")}} - {{cssxref(":future")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/display-internal/index.md
--- title: <display-internal> slug: Web/CSS/display-internal page-type: css-type browser-compat: - css.properties.display.table_values - css.properties.display.ruby_values --- {{CSSRef}} Some layout models such as `table` and `ruby` have a complex internal structure, with several different roles that their children and descendants can fill. This page defines those "internal" display values, which only have meaning within that particular layout mode. ## Syntax Valid `<display-internal>` values: - `table-row-group` - : These elements behave like {{HTMLElement("tbody")}} HTML elements. - `table-header-group` - : These elements behave like {{HTMLElement("thead")}} HTML elements. - `table-footer-group` - : These elements behave like {{HTMLElement("tfoot")}} HTML elements. - `table-row` - : These elements behave like {{HTMLElement("tr")}} HTML elements. - `table-cell` - : These elements behave like {{HTMLElement("td")}} HTML elements. - `table-column-group` - : These elements behave like {{HTMLElement("colgroup")}} HTML elements. - `table-column` - : These elements behave like {{HTMLElement("col")}} HTML elements. - `table-caption` - : These elements behave like {{HTMLElement("caption")}} HTML elements. - `ruby-base` {{Experimental_Inline}} - : These elements behave like {{HTMLElement("rb")}} HTML elements. - `ruby-text` {{Experimental_Inline}} - : These elements behave like {{HTMLElement("rt")}} HTML elements. - `ruby-base-container` {{Experimental_Inline}} - : These elements are generated as anonymous boxes. - `ruby-text-container` {{Experimental_Inline}} - : These elements behave like {{HTMLElement("rtc")}} HTML elements. ## Formal syntax {{csssyntax}} ## Examples ### CSS tables example The following example demonstrates laying out a simple form using CSS table layout. #### HTML ```html <main> <div> <label for="name">Name</label> <input type="text" id="name" name="name" /> </div> <div> <label for="age">Age</label> <input type="text" id="age" name="age" /> </div> </main> ``` #### CSS ```css main { display: table; } div { display: table-row; } label, input { display: table-cell; margin: 5px; } ``` #### Result {{EmbedLiveSample('CSS_tables_example', '100%', 100)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{CSSxRef("display")}} - {{CSSxRef("&lt;display-outside&gt;")}} - {{CSSxRef("&lt;display-inside&gt;")}} - {{CSSxRef("&lt;display-listitem&gt;")}} - {{CSSxRef("&lt;display-box&gt;")}} - {{CSSxRef("&lt;display-legacy&gt;")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_colon_lang/index.md
--- title: ":lang()" slug: Web/CSS/:lang page-type: css-pseudo-class browser-compat: css.selectors.lang --- {{CSSRef}} The **`:lang()`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) matches elements based on the language they are determined to be in. {{EmbedInteractiveExample("pages/tabbed/pseudo-class-function-lang.html", "tabbed-shorter")}} > **Note:** In HTML, the language is determined by a combination of the [`lang`](/en-US/docs/Web/HTML/Global_attributes#lang) attribute, the {{HTMLElement("meta")}} element, and possibly by information from the protocol (such as HTTP headers). For other document types there may be other document methods for determining the language. ## Syntax ### Formal syntax ```css-nolint :lang(<language-code> [,<language-code> ]*) /* ... */ } ``` ### Parameters - `<language-code>` - : A comma separated list of one or more {{cssxref("&lt;string&gt;")}}s that target an element with a language value according to [BCP 47](https://tools.ietf.org/html/bcp47) language codes. Matching by language range is case-insensitive. ## Description When selecting languages, there is implicit wildcard matching, so `:lang(de-DE)` will match `de-DE`, `de-DE-1996`, `de-Latn-DE`, `de-Latf-DE`, and `de-Latn-DE-1996`. Explicitly using wildcards must include a full match of a language subtag, so `:lang("*-F*")` is invalid but `:lang("*-Fr")` is valid. ## Examples ### Matching children of a given language In this example, the `:lang()` pseudo-class is used to match the parents of quote elements ({{htmlElement("q")}}) using [child combinators](/en-US/docs/Web/CSS/Child_combinator). Note that this doesn't illustrate the only way to do this, and that the best method to use depends on the type of document. Also note that {{glossary("Unicode")}} values are used to specify some of the special quote characters. #### HTML ```html <div lang="en"> <q>This English quote has a <q>nested</q> quote inside.</q> </div> <div lang="fr"> <q>This French quote has a <q>nested</q> quote inside.</q> </div> <div lang="de"> <q>This German quote has a <q>nested</q> quote inside.</q> </div> ``` #### CSS ```css :lang(en) > q { quotes: "\201C" "\201D" "\2018" "\2019"; } :lang(fr) > q { quotes: "« " " »"; } :lang(de) > q { quotes: "»" "«" "\2039" "\203A"; } ``` #### Result {{EmbedLiveSample('Matching_children_of_a_given_language', '', '80')}} ### Matching multiple languages The following example shows how to match multiple languages by providing a comma-separated list of language codes. It's also possible to use a wildcard to match languages in a given language range. ```css hidden p { margin: 0; } ``` #### CSS ```css /* Matches nl and de */ :lang("nl", "de") { color: green; } /* Omitting quotes & case-insensitive matching */ :lang(EN, FR) { color: blue; } /* Wildcard matching a language range */ :lang("*-Latn") { color: red; } ``` #### HTML ```html <p lang="nl">Dit is een Nederlandse paragraaf.</p> <p lang="de">Dies ist ein deutscher Satz.</p> <p lang="en">This is an English sentence.</p> <p lang="en-GB">Matching the language range of English.</p> <p lang="fr">Ceci est un paragraphe français.</p> <p lang="fr-Latn-FR">Ceci est un paragraphe français en latin.</p> ``` #### Result {{EmbedLiveSample('Matching_multiple_languages', '', '120')}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - The {{cssxref(":dir")}} pseudo-class that matches by directionality of text - HTML [`lang`](/en-US/docs/Web/HTML/Global_attributes#lang) attribute - HTML [`translate`](/en-US/docs/Web/HTML/Global_attributes#translate) attribute - {{RFC(5646, "Tags for Identifying Languages (also known as BCP 47)")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/counters/index.md
--- title: counters() slug: Web/CSS/counters page-type: css-function browser-compat: css.types.counters --- {{CSSRef}} The **`counters()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) enables combining markers when nesting counters. The function returns a string that concatenates the current values of the named and nested counters, if any are present, with the string provided. The third, optional parameter enables defining the list style. The `counters()` function is generally used within [pseudo-element](/en-US/docs/Web/CSS/Pseudo-elements) through the {{cssxref("content")}} property, but theoretically, it can be used wherever a [`<string>`](/en-US/docs/Web/CSS/string) value is supported. The `counters()` function has two forms: `counters(<name>, <string>)` and `counters(<name>, <string>, <style>)`. The generated text is the value of all counters with the given `<name>`, arranged from the outermost to the innermost, and separated by the specified `<string>`. The counters are rendered in the `<style>` indicated, defaulting to `decimal` if no `<style>` is specified. {{EmbedInteractiveExample("pages/tabbed/function-counters.html", "tabbed-standard")}} ## Syntax ```css /* Simple usage - style defaults to decimal */ counters(countername, '.'); /* changing the counter display */ counters(countername, '-', upper-roman) ``` A [counter](/en-US/docs/Web/CSS/CSS_counter_styles/Using_CSS_counters) has no visible effect by itself. The `counters()` function (and {{cssxref("counter", "counter()")}} function) is what makes it useful by returning developer-defined content. ### Values The `counters()` function accepts two or three parameters. The first parameter is the `<counter-name>`. The second parameter is the concatenator `<string>`. The optional third parameter is the `<counter-style>`. - `<counter-name>` - : A {{cssxref("&lt;custom-ident&gt;")}} identifying the counters, which is the same case-sensitive name used for the {{cssxref("counter-reset")}} and {{cssxref("counter-increment")}} properties. The name cannot start with two dashes and can't be `none`, `unset`, `initial`, or `inherit`. Alternatively, for inline, single-use counters, the {{cssxref("symbols")}} function can be used instead of a named counter in [browsers that support `symbols()`](/en-US/docs/Web/CSS/symbols#browser_compatibility). - {{cssxref("&lt;string&gt;")}} - : Any number of text characters. Non-Latin characters must be encoded using their Unicode escape sequences: for example, `\000A9` represents the copyright symbol. - `<counter-style>` - : A counter style name or a [`symbols()`](/en-US/docs/Web/CSS/symbols) function. The counter style name can be a simple predefined style such as numeric, alphabetic, or symbolic, a complex longhand predefined style such as East Asian or Ethiopic, or another [predefined counter style](/en-US/docs/Web/CSS/CSS_counter_styles). If omitted, the counter-style defaults to decimal. The return value is a string containing all the values of all the counters in the element's CSS counters set named `<counter-name>` in the counter style defined by `<counter-style>` (or decimal, if omitted). The return string is sorted in outermost-first to innermost-last order, joined by the `<string>` specified. > **Note:** For information about non-concatenated counters, see the {{cssxref("counter", "counter()")}} function, which omits the `<string>` as a parameter. ### Formal syntax {{CSSSyntax}} ## Examples ### Comparing default counter value to uppercase roman numerals This example includes two `counters()` functions: one with `<counter-style>` set and the other defaulting to `decimal`. #### HTML ```html <ol> <li> <ol> <li></li> <li></li> <li></li> </ol> </li> <li></li> <li></li> <li> <ol> <li></li> <li> <ol> <li></li> <li></li> <li></li> </ol> </li> </ol> </li> </ol> ``` #### CSS ```css-nolint ol { counter-reset: listCounter; } li { counter-increment: listCounter; } li::marker { content: counters(listCounter, ".", upper-roman) ") "; } li::before { content: counters(listCounter, ".") " == " counters(listCounter, ".", lower-roman); } ``` #### Result {{EmbedLiveSample("Comparing default counter value to uppercase roman numerals", "100%", 270)}} ### Comparing decimal-leading-zero counter value to lowercase letters This example includes three `counters()` functions, each with different `<string>` and `<counter-style>` values. #### HTML ```html <ol> <li> <ol> <li></li> <li></li> <li></li> </ol> </li> <li></li> <li></li> <li> <ol> <li></li> <li> <ol> <li></li> <li></li> <li></li> </ol> </li> </ol> </li> </ol> ``` #### CSS ```css-nolint ol { counter-reset: count; } li { counter-increment: count; } li::marker { content: counters(count, "-", decimal-leading-zero) ") "; } li::before { content: counters(count, "~", upper-alpha) " == " counters(count, "*", lower-alpha); } ``` #### Result {{EmbedLiveSample("Comparing decimal-leading-zero counter value to lowercase letters", "100%", 270)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Using CSS Counters](/en-US/docs/Web/CSS/CSS_counter_styles/Using_CSS_counters) - {{cssxref("counter-set")}} property - {{cssxref("counter-reset")}} property - {{cssxref("counter-increment")}} property - {{cssxref("@counter-style")}} at-rule - CSS [`counter()`](/en-US/docs/Web/CSS/counter) function - {{cssxref("::marker")}} pseudo-element - [CSS lists and counters](/en-US/docs/Web/CSS/CSS_lists) module - [CSS counter styles](/en-US/docs/Web/CSS/CSS_counter_styles) module - [CSS generated content](/en-US/docs/Web/CSS/CSS_generated_content) module
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/ident/index.md
--- title: <ident> slug: Web/CSS/ident page-type: css-type spec-urls: https://drafts.csswg.org/css-values/#css-identifier --- {{CSSRef}} The **`<ident>`** [CSS](/en-US/docs/Web/CSS) [data type](/en-US/docs/Web/CSS/CSS_Types) denotes an arbitrary string used as an {{glossary("identifier")}}. ## Syntax The syntax of `<custom-ident>` is similar to CSS identifiers (such as property names), except that it is [case-sensitive](https://en.wikipedia.org/wiki/Case_sensitivity). It consists of one or more characters, where characters can be any of the following: - any alphabetical character (`A` to `Z`, or `a` to `z`), - any decimal digit (`0` to `9`), - a hyphen (`-`), - an underscore (`_`), - an escaped character (preceded by a backslash, `\`), - a [Unicode](https://en.wikipedia.org/wiki/Unicode) character (in the format of a backslash, `\`, followed by one to six hexadecimal digits, representing its Unicode code point) Note that `id1`, `Id1`, `iD1` and `ID1` are all different identifiers as they are [case-sensitive](https://en.wikipedia.org/wiki/Case_sensitivity). On the other hand, as there are several ways to escape a character, `toto\?` and `toto\3F` are the same identifiers. ## Examples ### Valid identifiers ```plain example-good nono79 A mix of alphanumeric characters and numbers ground-level A mix of alphanumeric characters and a dash -test A dash followed by alphanumeric characters --toto A custom-property like identifier _internal An underscore followed by alphanumeric characters \22 toto A Unicode character followed by a sequence of alphanumeric characters bili\.bob A correctly escaped period ``` ### Invalid identifiers ```plain example-bad 34rem It must not start with a decimal digit. -12rad It must not start with a dash followed by a decimal digit. bili.bob Only alphanumeric characters, _, and - needn't be escaped. 'bilibob' This would be a {{CSSxRef("&lt;string&gt;")}}. "bilibob" This would be a {{CSSxRef("&lt;string&gt;")}}. ``` ## Specifications {{Specifications}} ## Browser compatibility _As this type is not a real type but a convenience type used to simplify the definition of other CSS syntax, there is no browser compatibility information as such._ ## See also - [&lt;custom-ident&gt;](/en-US/docs/Web/CSS/custom-ident) - [&lt;dashed-ident&gt;](/en-US/docs/Web/CSS/dashed-ident)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/text-combine-upright/index.md
--- title: text-combine-upright slug: Web/CSS/text-combine-upright page-type: css-property browser-compat: css.properties.text-combine-upright --- {{CSSRef}} The **`text-combine-upright`** [CSS](/en-US/docs/Web/CSS) property sets the combination of characters into the space of a single character. If the combined text is wider than 1em, the user agent must fit the contents within 1em. The resulting composition is treated as a single upright glyph for layout and decoration. This property only has an effect in vertical writing modes. This is used to produce an effect that is known as tate-chū-yoko <q lang="ja">縦中横</q> in Japanese, or as <q lang="zh-Hant">橫向文字</q> in Chinese. {{EmbedInteractiveExample("pages/css/text-combine-upright.html")}} ## Syntax ```css /* Keyword values */ text-combine-upright: none; text-combine-upright: all; /* Digits values */ text-combine-upright: digits; /* fits 2 consecutive digits horizontally inside vertical text */ text-combine-upright: digits 4; /* fits up to 4 consecutive digits horizontally inside vertical text */ /* Global values */ text-combine-upright: inherit; text-combine-upright: initial; text-combine-upright: revert; text-combine-upright: revert-layer; text-combine-upright: unset; ``` ### Values - `none` - : There is no special processing. - `all` - : Attempts to typeset all consecutive characters within the box horizontally, such that they take up the space of a single character within the vertical line of the box. - `digits <integer>?` - : Attempts to display a sequence of consecutive {{Glossary("ASCII")}} digits (U+0030–U+0039) that has as many or fewer characters than the specified integer, such that it takes up the space of a single character within the vertical line box. If the integer is omitted, it computes to 2. Integers outside the range of 2-4 are invalid. ## Formal definition {{CSSInfo}} ## Formal syntax {{csssyntax}} ## Examples ### Using 'all' with horizontal text The all value requires markup around every piece of horizontal text, but it is currently supported by more browsers than the digits value. #### HTML ```html <p lang="zh-Hant"> 民國<span class="num">105</span>年<span class="num">4</span>月<span class="num" >29</span >日 </p> ``` #### CSS ```css html { writing-mode: vertical-rl; font: 24px serif; } .num { text-combine-upright: all; } ``` #### Results {{EmbedLiveSample('Example using "all"', 250, 200)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref("writing-mode")}}, {{cssxref("text-orientation")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/background-origin/index.md
--- title: background-origin slug: Web/CSS/background-origin page-type: css-property browser-compat: css.properties.background-origin --- {{CSSRef}} The **`background-origin`** [CSS](/en-US/docs/Web/CSS) property sets the background's origin: from the border start, inside the border, or inside the padding. {{EmbedInteractiveExample("pages/css/background-origin.html")}} Note that `background-origin` is ignored when {{cssxref("background-attachment")}} is `fixed`. ## Syntax ```css /* Keyword values */ background-origin: border-box; background-origin: padding-box; background-origin: content-box; /* Global values */ background-origin: inherit; background-origin: initial; background-origin: revert; background-origin: revert-layer; background-origin: unset; ``` The `background-origin` property is specified as one of the keyword values listed below. ### Values - `border-box` - : The background is positioned relative to the border box. - `padding-box` - : The background is positioned relative to the padding box. - `content-box` - : The background is positioned relative to the content box. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Setting background origins ```css .example { border: 10px double; padding: 10px; background: url("image.jpg"); background-position: center left; background-origin: content-box; } ``` ```css #example2 { border: 4px solid black; padding: 10px; background: url("image.gif"); background-repeat: no-repeat; background-origin: border-box; } ``` ```css div { background-image: url("logo.jpg"), url("mainback.png"); /* Applies two images to the background */ background-position: top right, 0px 0px; background-origin: content-box, padding-box; } ``` ### Using two gradients In this example the box has a thick dotted border. The first gradient uses the `padding-box` as the `background-origin` and therefore the background sits inside the border. The second uses the `content-box` and so only displays behind the content. ```css .box { margin: 10px 0; color: #fff; background: linear-gradient( 90deg, rgb(131 58 180 / 100%) 0%, rgb(253 29 29 / 60%) 60%, rgb(252 176 69 / 100%) 100% ), radial-gradient(circle, rgb(255 255 255 / 100%) 0%, rgb(0 0 0 / 100%) 28%); border: 20px dashed black; padding: 20px; width: 400px; background-origin: padding-box, content-box; background-repeat: no-repeat; } ``` ```html <div class="box">Hello!</div> ``` {{EmbedLiveSample('Using_two_gradients', 420, 140)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref("background-clip")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/grid-template-columns/index.md
--- title: grid-template-columns slug: Web/CSS/grid-template-columns page-type: css-property browser-compat: css.properties.grid-template-columns --- {{CSSRef}} The **`grid-template-columns`** CSS property defines the line names and track sizing functions of the {{glossary("grid column", "grid columns")}}. {{EmbedInteractiveExample("pages/css/grid-template-columns.html")}} ## Syntax ```css /* Keyword value */ grid-template-columns: none; /* <track-list> values */ grid-template-columns: 100px 1fr; grid-template-columns: [linename] 100px; grid-template-columns: [linename1] 100px [linename2 linename3]; grid-template-columns: minmax(100px, 1fr); grid-template-columns: fit-content(40%); grid-template-columns: repeat(3, 200px); grid-template-columns: subgrid; grid-template-columns: masonry; /* <auto-track-list> values */ grid-template-columns: 200px repeat(auto-fill, 100px) 300px; grid-template-columns: minmax(100px, max-content) repeat(auto-fill, 200px) 20%; grid-template-columns: [linename1] 100px [linename2] repeat(auto-fit, [linename3 linename4] 300px) 100px; grid-template-columns: [linename1 linename2] 100px repeat(auto-fit, [linename1] 300px) [linename3]; /* Global values */ grid-template-columns: inherit; grid-template-columns: initial; grid-template-columns: revert; grid-template-columns: revert-layer; grid-template-columns: unset; ``` ### Values - `none` - : Indicates that there is no explicit grid. Any columns will be implicitly generated and their size will be determined by the {{cssxref("grid-auto-columns")}} property. - `[linename]` - : A [`<custom-ident>`](/en-US/docs/Web/CSS/custom-ident) specifying a name for the line in that location. The ident may be any valid string other than the reserved words `span` and `auto`. Lines may have multiple names separated by a space inside the square brackets, for example `[line-name-a line-name-b]`. - {{cssxref("&lt;length&gt;")}} - : A non-negative length, giving the width of the column. - {{cssxref("&lt;percentage&gt;")}} - : Is a non-negative {{cssxref("percentage", "&lt;percentage&gt;")}} value relative to the inline size of the grid container. If the size of the grid container depends on the size of its tracks, then the percentage must be treated as `auto`. The intrinsic size contributions of the track may be adjusted to the size of the grid container and increase the final size of the track by the minimum amount that would result in honoring the percentage. - {{cssxref("&lt;flex&gt;")}} - : Is a non-negative dimension with the unit `fr` specifying the track's flex factor. Each `<flex>`-sized track takes a share of the remaining space in proportion to its flex factor. When appearing outside a `minmax()` notation, it implies an automatic minimum (i.e. `minmax(auto, <flex>)`). - {{cssxref("max-content")}} - : Is a keyword representing the largest [maximal content contribution](https://www.w3.org/TR/css-sizing-3/#max-content) of the grid items occupying the grid track. For example, if the first element of the grid track contains the sentence _"Repetitio est mater studiorum"_ and the second element contains the sentence _"Dum spiro, spero"_, maximal content contribution will be defined by the size of the largest sentence among all of the grid elements - _"Repetitio est mater studiorum"_. - {{cssxref("min-content")}} - : Is a keyword representing the largest [minimal content contribution](https://www.w3.org/TR/css-sizing-3/#min-content) of the grid items occupying the grid track. For example, if the first element of the grid track contains the sentence _"Repetitio est mater studiorum"_ and the second element contains the sentence _"Dum spiro, spero"_, minimal content contribution will be defined by the size of the largest word among all of the sentences in the grid elements - _"studiorum"_. - {{cssxref("minmax", "minmax(min, max)")}} - : Is a functional notation that defines a size range greater than or equal to _min_ and less than or equal to _max_. If _max_ is smaller than _min_, then _max_ is ignored and the function is treated as _min_. As a maximum, a `<flex>` value sets the track's flex factor. It is invalid as a minimum. - `auto` - : As a maximum represents the largest {{cssxref("max-content")}} size of the items in that track. As a minimum represents the largest minimum size of items in that track (specified by the {{cssxref("min-width")}}/{{cssxref("min-height")}} of the items). This is often, though not always, the {{cssxref("min-content")}} size. If used outside of {{cssxref("minmax", "minmax()")}} notation, `auto` represents the range between the minimum and maximum described above. This behaves similarly to `minmax(min-content,max-content)` in most cases. > **Note:** `auto` track sizes (and only `auto` track sizes) can be stretched by the {{cssxref("align-content")}} and {{cssxref("justify-content")}} properties. Therefore by default, an `auto` sized track will take up any remaining space in the grid container. - `{{cssxref("fit-content_function", "fit-content( [ &lt;length&gt; | &lt;percentage&gt; ] )")}}` - : Represents the formula `max(minimum, min(limit, max-content))`, where _minimum_ represents an `auto` minimum (which is often, but not always, equal to a {{cssxref("min-content")}} minimum), and _limit_ is the track sizing function passed as an argument to fit-content(). This is essentially calculated as the smaller of `minmax(auto, max-content)` and `minmax(auto, limit)`. - {{cssxref("repeat", "repeat( [ &lt;positive-integer&gt; | auto-fill | auto-fit ] , &lt;track-list&gt; )")}} - : Represents a repeated fragment of the track list, allowing a large number of columns that exhibit a recurring pattern to be written in a more compact form. - [`masonry`](/en-US/docs/Web/CSS/CSS_grid_layout/Masonry_layout) {{Experimental_Inline}} - : The masonry value indicates that this axis should be laid out according to the masonry algorithm. - [`subgrid`](/en-US/docs/Web/CSS/CSS_grid_layout/Subgrid) - : The `subgrid` value indicates that the grid will adopt the spanned portion of its parent grid in that axis. Rather than being specified explicitly, the sizes of the grid rows/columns will be taken from the parent grid's definition. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Specifying grid column sizes #### HTML ```html <div id="grid"> <div id="areaA">A</div> <div id="areaB">B</div> </div> ``` #### CSS ```css #grid { display: grid; width: 100%; grid-template-columns: 50px 1fr; } #areaA { background-color: lime; } #areaB { background-color: yellow; } ``` #### Result {{EmbedLiveSample("Specifying_grid_column_sizes", "100%", "20px")}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - Related CSS properties: {{cssxref("grid-template-rows")}}, {{cssxref("grid-template-areas")}}, {{cssxref("grid-template")}} - Grid Layout Guide: _[Basic concepts of grid layout - Grid Tracks](/en-US/docs/Web/CSS/CSS_grid_layout/Basic_concepts_of_grid_layout#grid_tracks)_ - Video tutorial: _[Defining a Grid](https://gridbyexample.com/video/series-define-a-grid/)_ - [Subgrid](/en-US/docs/Web/CSS/CSS_grid_layout/Subgrid)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/clamp/index.md
--- title: clamp() slug: Web/CSS/clamp page-type: css-function browser-compat: css.types.clamp --- {{CSSRef}} The **`clamp()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) clamps a middle value within a range of values between a defined minimum bound and a maximum bound. The function takes three parameters: a minimum value, a preferred value, and a maximum allowed value. {{EmbedInteractiveExample("pages/css/function-clamp.html")}} Note that using `clamp()` for font sizes, as in these examples, allows you to set a font-size that grows with the size of the viewport, but doesn't go below a minimum font-size or above a maximum font-size. It has the same effect as the code in [Fluid Typography](https://css-tricks.com/snippets/css/fluid-typography/) but in one line, and without the use of media queries. ## Syntax ```css /* Static values */ width: clamp(200px, 40%, 400px); width: clamp(20rem, 30vw, 70rem); width: clamp(10vw, 20em, 100vw); /* Calculated values */ width: clamp(min(10vw, 20rem), 300px, max(90vw, 55rem)); width: clamp(100px, calc(30% / 2rem + 10px), 900px); ``` ### Parameters The `clamp(min, val, max)` function accepts three comma-separated expressions as its parameters. - `min` - : The minimum value is the smallest (most negative) value. This is the lower bound in the range of allowed values. If the preferred value is less than this value, the minimum value will be used. - `val` - : The preferred value is the expression whose value will be used as long as the result is between the minimum and maximum values. - `max` - : The maximum value is the largest (most positive) expression value to which the value of the property will be assigned if the preferred value is greater than this upper bound. The expressions can be math functions (see {{CSSxRef("calc", "calc()")}} for more information), literal values, other expressions that evaluate to a valid argument type (like {{CSSxRef("&lt;length&gt;")}}), or nested {{CSSxRef("min", "min()")}} and {{CSSxRef("max", "max()")}} functions. For math expressions, you can use addition, subtraction, multiplication, and division without using the `calc()` function itself. You may also use parentheses to establish computation order when needed. You can use different units for each value in your expressions and different units in any math function making up any of the arguments. Keep the following aspects in mind while working with the function: - Math expressions involving percentages for widths and heights on table columns, table column groups, table rows, table row groups, and table cells in both auto and fixed layout tables _may_ be treated as if `auto` had been specified. - It is permitted to nest `max()` and `min()` functions as expression values, in which case the inner ones are treated as simple parentheses. The expressions are full math expressions, so you can use direct addition, subtraction, multiplication and division without using the calc() function itself. - The expression can be values combining the addition ( `+` ), subtraction ( `-` ), multiplication ( `*` ) and division ( `/` ) operators, using standard operator precedence rules. Make sure to put a space on each side of the `+` and `-` operands. The operands in the expression may be any {{CSSxRef("&lt;length&gt;")}} syntax value. You can use different units for each value in your expression. You may also use parentheses to establish computation order when needed. - Oftentimes you will want to use {{CSSxRef("min", "min()")}} and {{CSSxRef("max", "max()")}} within a `clamp()` function. ### Return value `clamp(MIN, VAL, MAX)` is resolved as `{{CSSxRef("max", "max")}}(MIN, {{CSSxRef("min", "min")}}(VAL, MAX))`. Based on the provided parameters, the function returns {{CSSxRef("&lt;length&gt;")}}, {{CSSxRef("&lt;frequency&gt;")}}, {{CSSxRef("&lt;angle&gt;")}}, {{CSSxRef("&lt;time&gt;")}}, {{CSSxRef("&lt;percentage&gt;")}}, {{CSSxRef("&lt;number&gt;")}}, or {{CSSxRef("&lt;integer&gt;")}}. ### Formal syntax {{CSSSyntax}} ## Examples ### min(), max(), and clamp() comparison In this example we have a web page that uses {{CSSxRef("min", "min()")}}, {{CSSxRef("max", "max()")}}, and {{CSSxRef("clamp", "clamp()")}} to set sizes responsively. The example adjusts the sizes of page elements in three ways: - the lengths of the lines of text - the font size of paragraph text - the font size of heading text In all three cases, the page uses a combination of a viewport-relative units ([`vw`](/en-US/docs/Web/CSS/length#vw) and {{cssxref("percentage")}}), to set a size that varies with the viewport width, and a value that is not viewport relative ([`rem`](/en-US/docs/Web/CSS/length#rem) and [`px`](/en-US/docs/Web/CSS/length#px)) to implement minimum and/or maximum sizes. The example is at <https://mdn.github.io/css-examples/min-max-clamp/>. Open it in a new window and try adjusting the window width. The **line length** (controlled by the [`width`](/en-US/docs/Web/CSS/width) of the [`<body>`](/en-US/docs/Web/HTML/Element/body) element) will increase as the window width increases, but only up to a certain point (`1000px`), and beyond that point, it won't increase anymore. We're using `min()` to set a **maximum line length**: it can go under `1000px`, but won't go over. This is helpful because long lines are harder to read, so we often want to limit how long a line can be. To achieve this we use `min(1000px, calc(70% + 100px))`: when the result of the percentage-based calculation goes above `1000px`, we switch to the fixed `1000px` value. The **size of the paragraph text**, controlled by the [`font-size`](/en-US/docs/Web/CSS/font-size) of the [`<p>`](/en-US/docs/Web/HTML/Element/p) element, decreases as the window gets narrower, but only up to a certain point, and beyond that point (the point where `1.2vw` is less than `1.2rem`) it doesn't get any smaller: it stays at `1.2rem`. We're using `max()` to set a **minimum font size**: the font can grow above `1.2rem` but will never go below it. This is helpful because really small text is hard to read. To achieve this we use `max(1.2rem, 1.2vw)`. This means that the `font-size` will be set at `1.2rem`, unless the computed value of `1.2vw` is greater than that of `1.2rem`, in which case it will be set to `1.2vw` instead. The **size of the heading text**, controlled by the [`font-size`](/en-US/docs/Web/CSS/font-size) of the [`<h1>`](/en-US/docs/Web/HTML/Element/Heading_Elements) element, has a viewport-relative value with both a maximum and a minimum threshold. To achieve this we use `clamp(1.8rem, 2.5vw, 2.8rem)`. The viewport-relative value is `2.5vw` but it is clamped between `1.8rem` and `2.8rem`, so: - if the calculated value of `2.5vw` is less than `1.8rem`, then `1.8rem` will be used - if the calculated value of `2.5vw` is greater than `2.8rem`, then `2.8rem` will be used. This prevents the heading text from getting too small in a very narrow window, or too big in a very wide window. #### HTML ```html <h1>Simple responsive test</h1> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. In orci orci, eleifend id risus nec, mattis rutrum velit. Suspendisse fringilla egestas erat eu convallis. Phasellus eu velit ut magna dapibus elementum cursus at ligula. Ut tempus varius nibh, nec auctor sapien iaculis sit amet. Fusce iaculis, libero quis elementum viverra, nulla ante accumsan lectus, sit amet convallis lacus ipsum vel est. Curabitur et urna non est consectetur pulvinar vel id risus. Ut vestibulum, sem in semper aliquet, felis arcu euismod sapien, ac imperdiet massa nisl quis sem. Vestibulum ac elementum felis, in tempor velit. Pellentesque purus ex, mattis at ornare quis, porta condimentum mi. Donec vestibulum ligula vel nulla blandit, quis euismod nulla vestibulum. Suspendisse potenti. Nunc neque mauris, tempor sed facilisis at, ultrices eget nulla. Pellentesque convallis ante nec augue porttitor, id tempus ante luctus. </p> <p> Integer rutrum sollicitudin tellus, quis cursus nulla scelerisque nec. Nunc eu facilisis lorem. Maecenas faucibus sapien eleifend, semper tellus at, pharetra quam. Cras feugiat vulputate tortor at rhoncus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam non felis quis sem lobortis sodales vel id libero. Phasellus sit amet placerat lorem. </p> ``` #### CSS ```css html { font-family: sans-serif; } body { margin: 0 auto; width: min(1000px, calc(70% + 100px)); } h1 { letter-spacing: 2px; font-size: clamp(1.8rem, 2.5vw, 2.8rem); } p { line-height: 1.5; font-size: max(1.2rem, 1.2vw); } ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{CSSxRef("calc", "calc()")}} - {{CSSxRef("max", "max()")}} - {{CSSxRef("min", "min()")}} - [CSS Values](/en-US/docs/Learn/CSS/Building_blocks/Values_and_units)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/css_miscellaneous/index.md
--- title: CSS miscellaneous slug: Web/CSS/CSS_miscellaneous page-type: css-module --- {{CSSRef}} These pages contain CSS properties that are supported by browsers but either aren't included in a CSS specification, don't fit into any other CSS categories, or are experimental. ## Reference ### Properties - {{cssxref("all")}} - {{cssxref("text-rendering")}} ## Specifications _These properties are mostly unrelated to each other. Consult their individual pages for specifications._ ## Browser compatibility _These properties are mostly unrelated to each other. Consult their individual pages for availability in browsers._
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/break-before/index.md
--- title: break-before slug: Web/CSS/break-before page-type: css-property browser-compat: css.properties.break-before --- {{CSSRef}} The **`break-before`** [CSS](/en-US/docs/Web/CSS) property sets how page, column, or region breaks should behave before a generated box. If there is no generated box, the property is ignored. {{EmbedInteractiveExample("pages/css/break-before.html")}} ## Syntax ```css /* Generic break values */ break-before: auto; break-before: avoid; break-before: always; break-before: all; /* Page break values */ break-before: avoid-page; break-before: page; break-before: left; break-before: right; break-before: recto; break-before: verso; /* Column break values */ break-before: avoid-column; break-before: column; /* Region break values */ break-before: avoid-region; break-before: region; /* Global values */ break-before: inherit; break-before: initial; break-before: revert; break-before: revert-layer; break-before: unset; ``` Each possible break point (in other words, each element boundary) is affected by three properties: the {{cssxref("break-after")}} value of the previous element, the `break-before` value of the next element, and the {{cssxref("break-inside")}} value of the containing element. To determine if a break must be done, the following rules are applied: 1. If any of the three concerned values is a _forced break value_ (`always`, `left`, `right`, `page`, `column`, or `region`), it has precedence. If more than one of them are such a break, the one of the element that appears the latest in the flow is taken (i.e., the `break-before` value has precedence over the `break-after` value, which itself has precedence over the `break-inside` value). 2. If any of the three concerned values is an _avoid break value_ (`avoid`, `avoid-page`, `avoid-region`, or `avoid-column`), no such break will be applied at that point. Once forced breaks have been applied, soft breaks may be added if needed, but not on element boundaries that resolve in a corresponding `avoid` value. ### Values #### Generic break values - `auto` - : Allows, but does not force, any break (page, column, or region) to be inserted right before the principal box. - `avoid` - : Avoids any break (page, column, or region) from being inserted right before the principal box. - `always` {{experimental_inline}} - : Forces a page break right after the principal box. The type of this break is that of the immediately-containing fragmentation context. If we are inside a multicol container then it would force a column break, inside paged media (but not inside a multicol container) a page break. - `all` {{experimental_inline}} - : Forces a page break right after the principal box. Breaking through all possible fragmentation contexts. So a break inside a multicol container, which was inside a page container would force a column and page break. #### Page break values - `avoid-page` - : Avoids any page break right before the principal box. - `page` - : Forces a page break right before the principal box. - `left` - : Forces one or two page breaks right before the principal box, whichever will make the next page into a left page. It's the page placed on the left side of the spine of the book or the back side of the page in duplex printing. - `right` - : Forces one or two page breaks right before the principal box, whichever will make the next page into a right page. It's the page placed on the right side of the spine of the book or the front side of the page in duplex printing. - `recto` - : Forces one or two page breaks right before the principal box, whichever will make the next page into a recto page. (A recto page is a right page in a left-to-right spread or a left page in a right-to-left spread.) - `verso` - : Forces one or two page breaks right before the principal box, whichever will make the next page into a verso page. (A verso page is a left page in a left-to-right spread or a right page in a right-to-left spread.) #### Column break values - `avoid-column` - : Avoids any column break right before the principal box. - `column` - : Forces a column break right before the principal box. #### Region break values - `avoid-region` {{experimental_inline}} - : Avoids any region break right before the principal box. - `region` {{experimental_inline}} - : Forces a region break right before the principal box. ## Page break aliases For compatibility reasons, the legacy {{cssxref("page-break-before")}} property should be treated by browsers as an alias of `break-before`. This ensures that sites using `page-break-before` continue to work as designed. A subset of values should be aliased as follows: | page-break-before | break-before | | ----------------- | ------------ | | `auto` | `auto` | | `left` | `left` | | `right` | `right` | | `avoid` | `avoid` | | `always` | `page` | > **Note:** The `always` value of `page-break-*` was implemented by browsers as a page break, and not as a column break. Therefore the aliasing is to `page`, rather than the `always` value in the Level 4 spec. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Breaking into neat columns In the following example we have a container that contains an `<h1>` spanning all columns (achieved using `column-span: all`) and a series of `<h2>`s and paragraphs laid out in multiple columns using `column-width: 200px`. By default, the subheadings and paragraphs were laid out rather messily because the headings were not in a uniform place. However, we used `break-before: column` on the `<h2>` elements to force a column break before each one, meaning that you end up with an `<h2>` neatly at the top of each column. #### HTML ```html <article> <h1>Main heading</h1> <h2>Subheading</h2> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae fringilla mauris. Quisque commodo eget nisi sed pretium. Mauris luctus nec lacus in ultricies. Mauris vitae hendrerit arcu, ac scelerisque lacus. Aliquam lobortis in lacus sit amet posuere. Fusce iaculis urna id neque dapibus, eu lacinia lectus dictum. </p> <h2>Subheading</h2> <p> Praesent condimentum dui dui, sit amet rutrum diam tincidunt eu. Cras suscipit porta leo sit amet rutrum. Sed vehicula ornare tincidunt. Curabitur a ipsum ac diam mattis volutpat ac ut elit. Nullam luctus justo non vestibulum gravida. Morbi metus libero, pharetra non porttitor a, molestie nec nisi. </p> <h2>Subheading</h2> <p> Vivamus eleifend metus vitae neque placerat, eget interdum elit mattis. Donec eu vulputate nibh. Ut turpis leo, malesuada quis nisl nec, volutpat egestas tellus. </p> <h2>Subheading</h2> <p> In finibus viverra enim vel suscipit. Quisque consequat velit eu orci malesuada, ut interdum tortor molestie. Proin sed pellentesque augue. Nam risus justo, faucibus non porta a, congue vel massa. Cras luctus lacus nisl, sed tincidunt velit pharetra ac. Duis suscipit faucibus dui sed ultricies. </p> </article> ``` #### CSS ```css html { font-family: helvetica, arial, sans-serif; } h1 { font-size: 3rem; letter-spacing: 2px; column-span: all; } h2 { font-size: 1.2rem; color: red; letter-spacing: 1px; break-before: column; } p { line-height: 1.5; } article { column-width: 200px; gap: 20px; } ``` ### Result {{EmbedLiveSample('Breaking_into_neat_columns', '100%', 600)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Multiple-column Layout](/en-US/docs/Learn/CSS/CSS_layout/Multiple-column_Layout) - [Breaking Boxes With CSS Fragmentation](https://www.smashingmagazine.com/2019/02/css-fragmentation/)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/hex-color/index.md
--- title: <hex-color> slug: Web/CSS/hex-color page-type: css-type browser-compat: css.types.color.rgb_hexadecimal_notation --- {{CSSRef}} The **`<hex-color>`** [CSS](/en-US/docs/Web/CSS) [data type](/en-US/docs/Web/CSS/CSS_Types) is a notation for describing the _hexadecimal color syntax_ of an [sRGB](/en-US/docs/Glossary/RGB) color using its primary color components (red, green, blue) written as hexadecimal numbers, as well as its transparency. A `<hex-color>` value can be used everywhere where a [`<color>`](/en-US/docs/Web/CSS/color_value) can be used. ## Syntax ```plain #RGB // The three-value syntax #RGBA // The four-value syntax #RRGGBB // The six-value syntax #RRGGBBAA // The eight-value syntax ``` ### Value - `R` or `RR` - : The _red_ component of the color, as a case-insensitive hexadecimal number between `0` and `ff` (255). If there is only one number, it is duplicated: `1` means `11`. - `G` or `GG` - : The _green_ component of the color, as a case-insensitive hexadecimal number between `0` and `ff` (255). If there is only one number, it is duplicated: `c` means `cc`. - `B` or `BB` - : The _blue_ component of the color, as a case-insensitive hexadecimal number between `0` and `ff` (255). If there is only one number, it is duplicated: `9` means `99`. - `A` or `AA` {{optional_inline}} - : The _alpha_ component of the color, indicating its transparency, as a case-insensitive hexadecimal number between `0` and `ff` (255). If there is only one number, it is duplicated: `e` means `ee`. `0`, or `00`, represents a fully transparent color, and `f`, or `ff`, a fully opaque one. > **Note:** The syntax is case-insensitive: `#00ff00` is the same as `#00FF00`. ## Examples ### Hexadecimal syntax for a fully opaque hot pink #### HTML ```html <span> #f09 <div class="c1"></div> </span> <span> #F09 <div class="c2"></div> </span> <span> #ff0099 <div class="c3"></div> </span> <span> #FF0099 <div class="c4"></div> </span> ``` #### CSS ```css hidden body { display: flex; justify-content: space-evenly; } ``` ```css div { width: 40px; height: 40px; } .c1 { background: #f09; } .c2 { background: #f09; } .c3 { background: #ff0099; } .c4 { background: #ff0099; } ``` #### Result {{EmbedLiveSample("Hexadecimal_syntax_for_a_fully_opaque_hot_pink", "100%", 100)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [`<color>`](/en-US/docs/Web/CSS/color_value): the color data type - [`rgb()`](/en-US/docs/Web/CSS/color_value/rgb): the function allowing to set the three components of the color, as well as its transparency, using decimal values - [CSS color](/en-US/docs/Web/CSS/CSS_colors) module
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/css_animations/index.md
--- title: CSS animations slug: Web/CSS/CSS_animations page-type: css-module spec-urls: - https://drafts.csswg.org/css-animations-2/ - https://drafts.csswg.org/css-animations/ --- {{CSSRef}} The **CSS animations** module lets you animate the values of CSS properties, such as background-position and transform, over time by using keyframes. Each keyframe describes how the animated element should render at a given time during the animation sequence. You can use the properties in the animations module to control the duration, number of repetitions, delayed start, and other aspects of an animation. ### Animations in action To view the animation in the box below, click the checkbox 'Play the animation' or hover the cursor over the box. When the animating is active, the cloud at the top changes shape, snowflakes fall, and the snow level at the bottom rises. To pause the animation, uncheck the checkbox or move your cursor away from the box. {{EmbedGHLiveSample("css-examples/modules/animation.html", '100%', 650)}} This sample animation uses {{cssxref("animation-iteration-count")}} to make the flakes fall repeatedly, {{cssxref("animation-direction")}} to make the cloud move back and forth, {{cssxref("animation-fill-mode")}} to raise the snow level in response to the cloud movement, and {{cssxref("animation-play-state")}} to pause the animation. To see the code for this animation, [view the source on GitHub](https://github.com/mdn/css-examples/blob/main/modules/animation.html). ## Reference ### Properties - {{cssxref("animation")}} shorthand - {{cssxref("animation-composition")}} - {{cssxref("animation-delay")}} - {{cssxref("animation-direction")}} - {{cssxref("animation-duration")}} - {{cssxref("animation-fill-mode")}} - {{cssxref("animation-iteration-count")}} - {{cssxref("animation-name")}} - {{cssxref("animation-play-state")}} - {{cssxref("animation-timing-function")}} - {{cssxref("animation-timeline")}} ### At-rules - {{cssxref("@keyframes")}} ### Events All animations, even those with 0 seconds duration, throw animation events. - {{domxref("Element/animationstart_event", "animationstart")}} - {{domxref("Element/animationend_event", "animationend")}} - {{domxref("Element/animationcancel_event", "animationcancel")}} - {{domxref("Element/animationiteration_event", "animationiteration")}} ### Interfaces - [Web Animations API](/en-US/docs/Web/API/Web_Animations_API) - {{domxref("AnimationEvent")}} - {{domxref("CSSKeyframeRule")}} - {{domxref("CSSKeyframesRule")}} ## Guides - [Using CSS animations](/en-US/docs/Web/CSS/CSS_animations/Using_CSS_animations) - : Step-by-step tutorial on how to create animations using CSS. This article describes the animation-related CSS properties and at-rule and how they interact with each other. - [CSS animation tips and tricks](/en-US/docs/Web/CSS/CSS_animations/Tips) - : Tips and tricks to help you get the most out of CSS animations. ## Related concepts - {{cssxref("will-change")}} CSS property - [`<easing-function>`](/en-US/docs/Web/CSS/easing-function) data type - [`prefers-reduced-motion`](/en-US/docs/Web/CSS/@media/prefers-reduced-motion) media query - {{glossary("Bezier curve")}} glossary term ## Specifications {{Specifications}} ## See also - [CSS scroll-driven animations](/en-US/docs/Web/CSS/CSS_scroll-driven_animations) - Properties in the [transitions](/en-US/docs/Web/CSS/CSS_transitions) CSS module to trigger animations based on user actions - The {{htmlelement("canvas")}} HTML element along with [canvas API](/en-US/docs/Web/API/Canvas_API) and [WebGL API](/en-US/docs/Web/API/WebGL_API) to draw graphics and animations - The {{domxref("SVGAnimationElement")}} interface for all the animation-related element interfaces, including {{domxref("SVGAnimateElement")}}, {{domxref("SVGSetElement")}}, {{domxref("SVGAnimateColorElement")}}, {{domxref("SVGAnimateMotionElement")}}, and {{domxref("SVGAnimateTransformElement")}}
0
data/mdn-content/files/en-us/web/css/css_animations
data/mdn-content/files/en-us/web/css/css_animations/using_css_animations/index.md
--- title: Using CSS animations slug: Web/CSS/CSS_animations/Using_CSS_animations page-type: guide --- {{CSSRef}} **CSS animations** make it possible to animate transitions from one CSS style configuration to another. Animations consist of two components, a style describing the CSS animation and a set of keyframes that indicate the start and end states of the animation's style, as well as possible intermediate waypoints. There are three key advantages to CSS animations over traditional script-driven animation techniques: 1. They're easy to use for simple animations; you can create them without even having to know JavaScript. 2. The animations run well, even under moderate system load. Simple animations can often perform poorly in JavaScript. The rendering engine can use frame-skipping and other techniques to keep the performance as smooth as possible. 3. Letting the browser control the animation sequence lets the browser optimize performance and efficiency by, for example, reducing the update frequency of animations running in tabs that aren't currently visible. ## Configuring an animation To create a CSS animation sequence, you style the element you want to animate with the {{cssxref("animation")}} property or its sub-properties. This lets you configure the timing, duration, and other details of how the animation sequence should progress. This does **not** configure the actual appearance of the animation, which is done using the {{cssxref("@keyframes")}} at-rule as described in the [Defining animation sequence using keyframes](#defining_animation_sequence_using_keyframes) section below. The sub-properties of the {{cssxref("animation")}} property are: - {{cssxref("animation-composition")}} - : Specifies the {{Glossary("composite operation")}} to use when multiple animations affect the same property simultaneously. This property is not part of the `animation` shorthand property. - {{cssxref("animation-delay")}} - : Specifies the delay between an element loading and the start of an animation sequence and whether the animation should start immediately from its beginning or partway through the animation. - {{cssxref("animation-direction")}} - : Specifies whether an animation's first iteration should be forward or backward and whether subsequent iterations should alternate direction on each run through the sequence or reset to the start point and repeat. - {{cssxref("animation-duration")}} - : Specifies the length of time in which an animation completes one cycle. - {{cssxref("animation-fill-mode")}} - : Specifies how an animation applies styles to its target before and after it runs. - {{cssxref("animation-iteration-count")}} - : Specifies the number of times an animation should repeat. - {{cssxref("animation-name")}} - : Specifies the name of the {{cssxref("@keyframes")}} at-rule describing an animation's keyframes. - {{cssxref("animation-play-state")}} - : Specifies whether to pause or play an animation sequence. - {{cssxref("animation-timeline")}} {{experimental_inline}} - : Specifies the timeline that is used to control the progress of a CSS animation. - {{cssxref("animation-timing-function")}} - : Specifies how an animation transitions through keyframes by establishing acceleration curves. ## Defining animation sequence using keyframes After you've configured the animation's timing, you need to define the appearance of the animation. This is done by establishing one or more keyframes using the {{cssxref("@keyframes")}} at-rule. Each keyframe describes how the animated element should render at a given time during the animation sequence. Since the timing of the animation is defined in the CSS style that configures the animation, keyframes use a {{cssxref("percentage")}} to indicate the time during the animation sequence at which they take place. 0% indicates the first moment of the animation sequence, while 100% indicates the final state of the animation. Because these two times are so important, they have special aliases: `from` and `to`. Both are optional. If `from`/`0%` or `to`/`100%` is not specified, the browser starts or finishes the animation using the computed values of all attributes. You can optionally include additional keyframes that describe intermediate steps between the start and end of the animation. ## Using the animation shorthand The {{cssxref("animation")}} shorthand is useful for saving space. As an example, some of the rules we've been using through this article: ```css p { animation-duration: 3s; animation-name: slidein; animation-iteration-count: infinite; animation-direction: alternate; } ``` ...could be replaced by using the `animation` shorthand. ```css p { animation: 3s infinite alternate slidein; } ``` To learn more about the sequence in which different animation property values can be specified using the `animation` shorthand, see the {{cssxref("animation")}} reference page. ## Setting multiple animation property values The CSS animation longhand properties can accept multiple values, separated by commas. This feature can be used when you want to apply multiple animations in a single rule and set different durations, iteration counts, etc., for each of the animations. Let's look at some quick examples to explain the different permutations. In this first example, there are three duration and three iteration count values. So each animation is assigned a value of duration and iteration count with the same position as the animation name. The `fadeInOut` animation is assigned a duration of `2.5s` and an iteration count of `2`, and the `bounce` animation is assigned a duration of `1s` and an iteration count of `5`. ```css animation-name: fadeInOut, moveLeft300px, bounce; animation-duration: 2.5s, 5s, 1s; animation-iteration-count: 2, 1, 5; ``` In this second example, three animation names are set, but there's only one duration and iteration count. In this case, all three animations are given the same duration and iteration count. ```css animation-name: fadeInOut, moveLeft300px, bounce; animation-duration: 3s; animation-iteration-count: 1; ``` In this third example, three animations are specified, but only two durations and iteration counts. In such cases where there are not enough values in the list to assign a separate one to each animation, the value assignment cycles from the first to the last item in the available list and then cycles back to the first item. So, `fadeInOut` gets a duration of `2.5s`, and `moveLeft300px` gets a duration of `5s`, which is the last value in the list of duration values. The duration value assignment now resets to the first value; `bounce`, therefore, gets a duration of `2.5s`. The iteration count values (and any other property values you specify) will be assigned in the same way. ```css animation-name: fadeInOut, moveLeft300px, bounce; animation-duration: 2.5s, 5s; animation-iteration-count: 2, 1; ``` If the mismatch in the number of animations and animation property values is inverted, say there are five `animation-duration` values for three `animation-name` values, then the extra or unused animation property values, in this case, two `animation-duration` values, don't apply to any animation and are ignored. ## Examples > **Note:** Some older browsers (pre-2017) may need prefixes; the live examples you can click to see in your browser include the `-webkit` prefixed syntax. ### Making text slide across the browser window This simple example styles the {{HTMLElement("p")}} element so that the text slides in from off the right edge of the browser window. Note that animations like this can cause the page to become wider than the browser window. To avoid this problem put the element to be animated in a container, and set {{cssxref("overflow")}}`:hidden` on the container. ```css p { animation-duration: 3s; animation-name: slidein; } @keyframes slidein { from { margin-left: 100%; width: 300%; } to { margin-left: 0%; width: 100%; } } ``` In this example the style for the {{HTMLElement("p")}} element specifies that the animation should take 3 seconds to execute from start to finish, using the {{cssxref("animation-duration")}} property, and that the name of the {{ cssxref("@keyframes")}} at-rule defining the keyframes for the animation sequence is named "slidein". If we wanted any custom styling on the {{HTMLElement("p")}} element to appear in browsers that don't support CSS animations, we would include it here as well; however, in this case we don't want any custom styling other than the animation effect. The keyframes are defined using the {{cssxref("@keyframes")}} at-rule. In this case, we have just two keyframes. The first occurs at 0% (using the alias `from`). Here, we configure the left margin of the element to be at 100% (that is, at the far right edge of the containing element), and the width of the element to be 300% (or three times the width of the containing element). This causes the first frame of the animation to have the header drawn off the right edge of the browser window. The second (and final) keyframe occurs at 100% (using the alias `to`). The left margin is set to 0% and the width of the element is set to 100%. This causes the header to finish its animation flush against the left edge of the content area. ```html <p> The Caterpillar and Alice looked at each other for some time in silence: at last the Caterpillar took the hookah out of its mouth, and addressed her in a languid, sleepy voice. </p> ``` > **Note:** Reload page to see the animation. {{EmbedLiveSample("Making_text_slide_across_the_browser_window","100%","250")}} ### Adding another keyframe Let's add another keyframe to the previous example's animation. Let's say we want the header's font size to increase as it moves from right to left for a while, then to decrease back to its original size. That's as simple as adding this keyframe: ```css 75% { font-size: 300%; margin-left: 25%; width: 150%; } ``` The full code now looks like this: ```css p { animation-duration: 3s; animation-name: slidein; } @keyframes slidein { from { margin-left: 100%; width: 300%; } 75% { font-size: 300%; margin-left: 25%; width: 150%; } to { margin-left: 0%; width: 100%; } } ``` ```html <p> The Caterpillar and Alice looked at each other for some time in silence: at last the Caterpillar took the hookah out of its mouth, and addressed her in a languid, sleepy voice. </p> ``` This tells the browser that 75% of the way through the animation sequence, the header should have its left margin at 25% and the width should be 150%. > **Note:** Reload page to see the animation. {{EmbedLiveSample("Adding_another_keyframe","100%","250")}} ### Repeating the animation To make the animation repeat itself, use the {{cssxref("animation-iteration-count")}} property to indicate how many times to repeat the animation. In this case, let's use `infinite` to have the animation repeat indefinitely: ```css p { animation-duration: 3s; animation-name: slidein; animation-iteration-count: infinite; } ``` Adding it to the existing code: ```css @keyframes slidein { from { margin-left: 100%; width: 300%; } to { margin-left: 0%; width: 100%; } } ``` ```html <p> The Caterpillar and Alice looked at each other for some time in silence: at last the Caterpillar took the hookah out of its mouth, and addressed her in a languid, sleepy voice. </p> ``` {{EmbedLiveSample("Repeating_the_animation","100%","250")}} ### Making the animation move back and forth That made it repeat, but it's very odd having it jump back to the start each time it begins animating. What we really want is for it to move back and forth across the screen. That's easily accomplished by setting {{cssxref("animation-direction")}} to `alternate`: ```css p { animation-duration: 3s; animation-name: slidein; animation-iteration-count: infinite; animation-direction: alternate; } ``` And the rest of the code: ```css @keyframes slidein { from { margin-left: 100%; width: 300%; } to { margin-left: 0%; width: 100%; } } ``` ```html <p> The Caterpillar and Alice looked at each other for some time in silence: at last the Caterpillar took the hookah out of its mouth, and addressed her in a languid, sleepy voice. </p> ``` {{EmbedLiveSample("Making_the_animation_move_back_and_forth","100%","250")}} ### Using animation events You can get additional control over animations — as well as useful information about them — by making use of animation events. These events, represented by the {{domxref("AnimationEvent")}} object, can be used to detect when animations start, finish, and begin a new iteration. Each event includes the time at which it occurred as well as the name of the animation that triggered the event. We'll modify the sliding text example to output some information about each animation event when it occurs, so we can get a look at how they work. #### Adding the CSS We start with creating the CSS for the animation. This animation will last for 3 seconds, be called "slidein", repeat 3 times, and alternate direction each time. In the {{cssxref("@keyframes")}}, the width and margin-left are manipulated to make the element slide across the screen. ```css .slidein { animation-duration: 3s; animation-name: slidein; animation-iteration-count: 3; animation-direction: alternate; } @keyframes slidein { from { margin-left: 100%; width: 300%; } to { margin-left: 0%; width: 100%; } } ``` #### Adding the animation event listeners We'll use JavaScript code to listen for all three possible animation events. This code configures our event listeners; we call it when the document is first loaded in order to set things up. ```js const element = document.getElementById("watchme"); element.addEventListener("animationstart", listener, false); element.addEventListener("animationend", listener, false); element.addEventListener("animationiteration", listener, false); element.className = "slidein"; ``` This is pretty standard code; you can get details on how it works in the documentation for {{domxref("eventTarget.addEventListener()")}}. The last thing this code does is set the `class` on the element we'll be animating to "slidein"; we do this to start the animation. Why? Because the `animationstart` event fires as soon as the animation starts, and in our case, that happens before our code runs. So we'll start the animation ourselves by setting the class of the element to the style that gets animated after the fact. #### Receiving the events The events get delivered to the `listener()` function, which is shown below. ```js function listener(event) { const l = document.createElement("li"); switch (event.type) { case "animationstart": l.textContent = `Started: elapsed time is ${event.elapsedTime}`; break; case "animationend": l.textContent = `Ended: elapsed time is ${event.elapsedTime}`; break; case "animationiteration": l.textContent = `New loop started at time ${event.elapsedTime}`; break; } document.getElementById("output").appendChild(l); } ``` This code, too, is very simple. It looks at the {{domxref("event.type")}} to determine which kind of animation event occurred, then adds an appropriate note to the {{HTMLElement("ul")}} (unordered list) we're using to log these events. The output, when all is said and done, looks something like this: - Started: elapsed time is 0 - New loop started at time 3.01200008392334 - New loop started at time 6.00600004196167 - Ended: elapsed time is 9.234000205993652 Note that the times are very close to, but not exactly, those expected given the timing established when the animation was configured. Note also that after the final iteration of the animation, the `animationiteration` event isn't sent; instead, the `animationend` event is sent. Just for the sake of completeness, here's the HTML that displays the page content, including the list into which the script inserts information about the received events: ```html <h1 id="watchme">Watch me move</h1> <p> This example shows how to use CSS animations to make <code>H1</code> elements move across the page. </p> <p> In addition, we output some text each time an animation event fires, so you can see them in action. </p> <ul id="output"></ul> ``` And here's the live output. > **Note:** Reload page to see the animation. {{EmbedLiveSample('Using_animation_events', '600', '300')}} ### Animating display and content-visibility This example demonstrates how [`display`](/en-US/docs/Web/CSS/display) and [`content-visibility`](/en-US/docs/Web/CSS/content-visibility) can be animated. This behavior is useful for creating entry/exit animations where you want to for example remove a container from the DOM with `display: none`, but have it fade out smoothly with [`opacity`](/en-US/docs/Web/CSS/opacity) rather than disappearing immediately. Supporting browsers animate `display` and `content-visibility` with a variation on the [discrete animation type](/en-US/docs/Web/CSS/CSS_animated_properties#discrete). This generally means that properties will flip between two values 50% of the way through animating between the two. There is an exception, however, which is when animating to/from `display: none` or `content-visibility: hidden` to a visible value. In this case, the browser will flip between the two values so that the animated content is shown for the entire animation duration. So for example: - When animating `display` from `none` to `block` (or another visible `display` value), the value will flip to `block` at `0%` of the animation duration so it is visible throughout. - When animating `display` from `block` (or another visible `display` value) to `none`, the value will flip to `none` at `100%` of the animation duration so it is visible throughout. #### HTML The HTML contains two {{htmlelement("p")}} elements with a {{htmlelement("div")}} in between that we will animate from `display` `none` to `block`. ```html <p> Click anywhere on the screen or press any key to toggle the <code>&lt;div&gt;</code> between hidden and showing. </p> <div> This is a <code>&lt;div&gt;</code> element that animates between <code>display: none; opacity: 0</code> and <code>display: block; opacity: 1</code>. Neat, huh? </div> <p> This is another paragraph to show that <code>display: none; </code> is being applied and removed on the above <code>&lt;div&gt; </code>. If only its <code>opacity</code> was being changed, it would always take up the space in the DOM. </p> ``` #### CSS ```css html { height: 100vh; } div { font-size: 1.6rem; padding: 20px; border: 3px solid red; border-radius: 20px; width: 480px; opacity: 0; display: none; } /* Animation classes */ div.fade-in { display: block; animation: fade-in 0.7s ease-in forwards; } div.fade-out { animation: fade-out 0.7s ease-out forwards; } /* Animation keyframes */ @keyframes fade-in { 0% { opacity: 0; display: none; } 100% { opacity: 1; display: block; } } @keyframes fade-out { 0% { opacity: 1; display: block; } 100% { opacity: 0; display: none; } } ``` Note the inclusion of the `display` property in the keyframe animations. #### JavaScript Finally, we include a bit of JavaScript to set up event listeners to trigger the animations. Specifically, we add the `fade-in` class to the `<div>` when we want it to appear, and `fade-out` when we want it to disappear. ```js const divElem = document.querySelector("div"); const htmlElem = document.querySelector(":root"); htmlElem.addEventListener("click", showHide); document.addEventListener("keydown", showHide); function showHide() { if (divElem.classList[0] === "fade-in") { divElem.classList.remove("fade-in"); divElem.classList.add("fade-out"); } else { divElem.classList.remove("fade-out"); divElem.classList.add("fade-in"); } } ``` #### Result The code renders as follows: {{ EmbedLiveSample("Animating display and content-visibility", "100%", "350") }} ## See also - {{domxref("AnimationEvent", "AnimationEvent")}} - [CSS animation tips and tricks](/en-US/docs/Web/CSS/CSS_animations/Tips) - [Using CSS transitions](/en-US/docs/Web/CSS/CSS_transitions/Using_CSS_transitions)
0
data/mdn-content/files/en-us/web/css/css_animations
data/mdn-content/files/en-us/web/css/css_animations/tips/index.md
--- title: CSS animation tips and tricks slug: Web/CSS/CSS_animations/Tips page-type: guide --- {{CSSRef}} CSS animations make it possible to do incredible things with the elements that make up your documents and apps. However, there are things you might want to do that aren't obvious, or clever ways to do things that you might not come up with right away. This article is a collection of tips and tricks we've found that may make your work easier, including how to run a stopped animation again. ## Run an animation again The [CSS Animations](/en-US/docs/Web/CSS/CSS_animations) specification doesn't offer a way to run an animation again. There's no magic `resetAnimation()` method on elements, and you can't even just set the element's {{cssxref("animation-play-state")}} to `"running"` again. Instead, you have to use clever tricks to get a stopped animation to replay. Here's one way to do it that we feel is stable and reliable enough to suggest to you. ### HTML First, let's define the HTML for a {{HTMLElement("div")}} we wish to animate and a button that will play (or replay) the animation. ```html <div class="box"></div> <div class="runButton">Click me to run the animation</div> ``` ### CSS Now we'll define the animation itself using CSS. Some CSS that's not important (the style of the "Run" button itself) isn't shown here, for brevity. ```css hidden .runButton { cursor: pointer; width: 300px; border: 1px solid black; font-size: 16px; text-align: center; margin-top: 12px; padding-top: 2px; padding-bottom: 4px; color: white; background-color: darkgreen; font: 14px "Open Sans", "Arial", sans-serif; } ``` ```css @keyframes colorchange { 0% { background: yellow; } 100% { background: blue; } } .box { width: 100px; height: 100px; border: 1px solid black; } .changing { animation: colorchange 2s; } ``` There are two classes here. The `"box"` class is the basic description of the box's appearance, without any animation information included. The animation details are included in the `"changing"` class, which says that the {{cssxref("@keyframes")}} named `"colorchange"` should be used over the course of two seconds to animate the box. Note that because of this, the box doesn't start with any animation effects in place, so it won't be animating. ### JavaScript Next we'll look at the JavaScript that does the work. The meat of this technique is in the `play()` function, which is called when the user clicks on the "Run" button. ```js function play() { document.querySelector(".box").className = "box"; requestAnimationFrame((time) => { requestAnimationFrame((time) => { document.querySelector(".box").className = "box changing"; }); }); } ``` This looks weird, doesn't it? That's because the only way to play an animation again is to remove the animation effect, let the document recompute styles so that it knows you've done that, then add the animation effect back to the element. To make that happen, we have to be creative. Here's what happens when the `play()` function gets called: 1. The box's list of CSS classes is reset to `"box"`. This has the effect of removing any other classes currently applied to the box, including the `"changing"` class that handles animation. In other words, we're removing the animation effect from the box. However, changes to the class list don't take effect until the style recomputation is complete and a refresh has occurred to reflect the change. 2. To be sure that the styles are recalculated, we use {{domxref("window.requestAnimationFrame()")}}, specifying a callback. Our callback gets executed just before the next repaint of the document. The problem for us is that because it's before the repaint, the style recomputation hasn't actually happened yet! 3. Our callback cleverly calls `requestAnimationFrame()` a second time! This time, the callback is run before the next repaint, which is after the style recomputation has occurred. This callback adds the `"changing"` class back onto the box, so that the repaint will start the animation once again. Of course, we also need to add an event handler to our "Run" button so it'll actually do something: ```js document.querySelector(".runButton").addEventListener("click", play, false); ``` ### Result {{ EmbedLiveSample('Run_an_animation_again', 320, 160) }} ## Stopping an animation Removing the {{cssxref("animation-name")}} applied to an element will make it jump or cut to its next state. If instead you'd like the animation to complete and then come to a stop you have to try a different approach. The main tricks are: 1. Make your animation as self-contained as possible. This means you should not rely on `animation-direction: alternate`. Instead you should explicitly write a keyframe animation that goes through the full animation in one forward repetition. 2. Use JavaScript and clear the animation being used when the `animationiteration` event fires. The following demo shows how you'd achieve the aforementioned JavaScript technique: ```css .slidein { animation-duration: 5s; animation-name: slidein; animation-iteration-count: infinite; } .stopped { animation-name: none; } @keyframes slidein { 0% { margin-left: 0%; } 50% { margin-left: 50%; } 100% { margin-left: 0%; } } ``` ```html <h1 id="watchme">Click me to stop</h1> ``` ```js const watchme = document.getElementById("watchme"); watchme.className = "slidein"; const listener = (e) => { watchme.className = "slidein stopped"; }; watchme.addEventListener("click", () => watchme.addEventListener("animationiteration", listener, false), ); ``` Demo <https://jsfiddle.net/morenoh149/5ty5a4oy/> ## See also - [Using CSS transitions](/en-US/docs/Web/CSS/CSS_transitions/Using_CSS_transitions) - {{domxref("Window.requestAnimationFrame()")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/text-indent/index.md
--- title: text-indent slug: Web/CSS/text-indent page-type: css-property browser-compat: css.properties.text-indent --- {{CSSRef}} The **`text-indent`** CSS property sets the length of empty space (indentation) that is put before lines of text in a block. {{EmbedInteractiveExample("pages/css/text-indent.html")}} Horizontal spacing is with respect to the left (or right, for right-to-left layout) edge of the containing block-level element's content box. ## Syntax ```css /* <length> values */ text-indent: 3mm; text-indent: 40px; /* <percentage> value relative to the containing block width */ text-indent: 15%; /* Keyword values */ text-indent: 5em each-line; text-indent: 5em hanging; text-indent: 5em hanging each-line; /* Global values */ text-indent: inherit; text-indent: initial; text-indent: revert; text-indent: revert-layer; text-indent: unset; ``` ### Values - {{cssxref("&lt;length&gt;")}} - : Indentation is specified as an absolute {{cssxref("&lt;length&gt;")}}. Negative values are allowed. See {{cssxref("&lt;length&gt;")}} values for possible units. - {{cssxref("&lt;percentage&gt;")}} - : Indentation is a {{cssxref("&lt;percentage&gt;")}} of the containing block's width. - `each-line` - : Indentation affects the first line of the block container as well as each line after a _forced line break_, but does not affect lines after a _soft wrap break_. - `hanging` - : Inverts which lines are indented. All lines _except_ the first line will be indented. ## Formal definition {{CSSInfo}} ## Formal syntax {{csssyntax}} ## Examples ### Simple indent #### HTML ```html <p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </p> <p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </p> ``` #### CSS ```css p { text-indent: 5em; background: powderblue; } ``` #### Result {{ EmbedLiveSample('Simple_indent','100%','100%') }} ### Skipping indentation on the first paragraph A common typographic practice when paragraph indentation is present is to skip the indentation for the first paragraph. As the _The Chicago Manual of Style_ puts it, "the first line of text following a subhead may begin flush left or be indented by the usual paragraph indention." Treating first paragraphs differently from subsequent paragraphs can be done using the [next-sibling combinator](/en-US/docs/Web/CSS/Next-sibling_combinator), as in the following example: #### HTML ```html <h2>Lorem ipsum</h2> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse eu venenatis quam. Vivamus euismod eleifend metus vitae pharetra. In vel tempor metus. Donec dapibus feugiat euismod. Vivamus interdum tellus dolor. Vivamus blandit eros et imperdiet auctor. Mauris sapien nunc, condimentum a efficitur non, elementum ac sapien. Cras consequat turpis non augue ullamcorper, sit amet porttitor dui interdum. </p> <p> Sed laoreet luctus erat at rutrum. Proin velit metus, luctus in sapien in, tincidunt mattis ex. Praesent venenatis orci at sagittis eleifend. Nulla facilisi. In feugiat vehicula magna iaculis vehicula. Nulla suscipit tempor odio a semper. Donec vitae dapibus ipsum. Donec libero purus, convallis eu efficitur id, pulvinar elementum diam. Maecenas mollis blandit placerat. Ut gravida pellentesque nunc, in eleifend ante convallis sit amet. </p> <h2>Donec ullamcorper elit nisl</h2> <p> Donec ullamcorper elit nisl, sagittis bibendum massa gravida in. Fusce tempor in ante gravida iaculis. Integer posuere tempor metus. Vestibulum lacinia, nunc et dictum viverra, urna massa aliquam tellus, id mollis sem velit vestibulum nulla. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec vulputate leo ut iaculis ultrices. Cras egestas rhoncus lorem. Nunc blandit tempus lectus, rutrum hendrerit orci eleifend id. Ut at quam velit. </p> <p> Aenean rutrum tempor ligula, at luctus ligula auctor vestibulum. Sed sollicitudin velit in leo fringilla sollicitudin. Proin eu gravida arcu. Nam iaculis malesuada massa, eget aliquet turpis sagittis sed. Sed mollis tellus ac dui ullamcorper, nec lobortis diam pellentesque. Quisque dapibus accumsan libero, sed euismod ipsum ullamcorper sed. </p> ``` #### CSS ```css p { text-align: justify; margin: 1em 0 0 0; } p + p { text-indent: 2em; margin: 0; } ``` #### Result {{ EmbedLiveSample('Skipping_indentation_on_the_first_paragraph','','500px') }} ### Percentage indent #### HTML ```html <p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </p> <p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </p> ``` #### CSS ```css p { text-indent: 30%; background: plum; } ``` #### Result {{ EmbedLiveSample('Percentage_indent','100%','100%') }} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Learn to style HTML using CSS](/en-US/docs/Learn/CSS) - Related CSS properties: - [`text-justify`](/en-US/docs/Web/CSS/text-justify) - [`text-orientation`](/en-US/docs/Web/CSS/text-orientation) - [`text-overflow`](/en-US/docs/Web/CSS/text-overflow) - [`text-rendering`](/en-US/docs/Web/CSS/text-rendering) - [`text-transform`](/en-US/docs/Web/CSS/text-transform) - {{cssxref('hanging-punctuation')}} - [CSS Text Decoration](/en-US/docs/Web/CSS/CSS_text_decoration) CSS module - [CSS Text module](/en-US/docs/Web/CSS/CSS_text)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_doublecolon_-webkit-search-results-button/index.md
--- title: "::-webkit-search-results-button" slug: Web/CSS/::-webkit-search-results-button page-type: css-pseudo-element status: - non-standard browser-compat: css.selectors.-webkit-search-results-button --- {{CSSRef}}{{Non-standard_header}} The **`::-webkit-search-results-button`** CSS [pseudo-element](/en-US/docs/Web/CSS/Pseudo-elements) represents a button (the "search results button") at the left edge of an {{HTMLElement("input")}} of `type="search"` which when clicked displays a menu which allows the user to choose from previous recent search queries. This button and pseudo-element are non-standard, supported only in WebKit and Blink, hence the vendor prefix. The search results button is only shown on search {{HTMLElement("input")}} elements that have a [`results`](/en-US/docs/Web/HTML/Element/input#results) attribute. ## Syntax ```css selector::-webkit-search-results-button { /* ... */ } ``` ## Specifications Not part of any standard. ## Browser compatibility {{Compat}} ## See also - {{cssxref('::-webkit-search-cancel-button')}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_colon_default/index.md
--- title: ":default" slug: Web/CSS/:default page-type: css-pseudo-class browser-compat: css.selectors.default --- {{CSSRef}} The **`:default`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) selects form elements that are the default in a group of related elements. {{EmbedInteractiveExample("pages/tabbed/pseudo-class-default.html", "tabbed-shorter")}} What this selector matches is defined in [HTML Standard §4.16.3 Pseudo-classes](https://html.spec.whatwg.org/multipage/semantics-other.html#selector-default) — it may match the {{htmlelement("button")}}, [`<input type="checkbox">`](/en-US/docs/Web/HTML/Element/input/checkbox), [`<input type="radio">`](/en-US/docs/Web/HTML/Element/input/radio), and {{htmlelement("option")}} elements: - A default option element is the first one with the `selected` attribute, or the first enabled option in DOM order. `multiple` {{htmlelement("select")}}s can have more than one `selected` option, so all will match `:default`. - `<input type="checkbox">` and `<input type="radio">` match if they have the `checked` attribute. - {{htmlelement("button")}} matches if it is a {{htmlelement("form")}}'s [default submission button](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#implicit-submission): the first `<button>` in DOM order that belongs to the form. This also applies to {{htmlelement("input")}} types that submit forms, like `image` or `submit`. ## Syntax ```css :default { /* ... */ } ``` ## Examples ### HTML ```html <fieldset> <legend>Favorite season</legend> <input type="radio" name="season" id="spring" value="spring" /> <label for="spring">Spring</label> <input type="radio" name="season" id="summer" value="summer" checked /> <label for="summer">Summer</label> <input type="radio" name="season" id="fall" value="fall" /> <label for="fall">Fall</label> <input type="radio" name="season" id="winter" value="winter" /> <label for="winter">Winter</label> </fieldset> ``` ### CSS ```css input:default { box-shadow: 0 0 2px 1px coral; } input:default + label { color: coral; } ``` ### Result {{EmbedLiveSample("Examples")}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Web forms — Working with user data](/en-US/docs/Learn/Forms) - [Styling web forms](/en-US/docs/Learn/Forms/Styling_web_forms) - Related HTML elements: {{htmlelement("button")}}, [`<input type="checkbox">`](/en-US/docs/Web/HTML/Element/input/checkbox), [`<input type="radio">`](/en-US/docs/Web/HTML/Element/input/radio), and {{htmlelement("option")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/margin-right/index.md
--- title: margin-right slug: Web/CSS/margin-right page-type: css-property browser-compat: css.properties.margin-right --- {{CSSRef}} The **`margin-right`** [CSS](/en-US/docs/Web/CSS) property sets the [margin area](/en-US/docs/Web/CSS/CSS_box_model/Introduction_to_the_CSS_box_model#margin_area) on the right side of an element. A positive value places it farther from its neighbors, while a negative value places it closer. {{EmbedInteractiveExample("pages/css/margin-right.html")}} The vertical margins of two adjacent boxes may fuse. This is called [_margin collapsing_](/en-US/docs/Web/CSS/CSS_box_model/Mastering_margin_collapsing). ## Syntax ```css /* <length> values */ margin-right: 20px; /* An absolute length */ margin-right: 1em; /* relative to the text size */ margin-right: 5%; /* relative to the nearest block container's width */ /* Keyword values */ margin-right: auto; /* Global values */ margin-right: inherit; margin-right: initial; margin-right: revert; margin-right: revert-layer; margin-right: unset; ``` The `margin-right` property is specified as the keyword `auto`, or a `<length>`, or a `<percentage>`. Its value can be positive, zero, or negative. ### Values - {{cssxref("&lt;length&gt;")}} - : The size of the margin as a fixed value. - {{cssxref("&lt;percentage&gt;")}} - : The size of the margin as a percentage, relative to the inline size (_width_ in a horizontal language, defined by {{cssxref("writing-mode")}}) of the [containing block](/en-US/docs/Web/CSS/Containing_block). - `auto` - : The right margin receives a share of the unused horizontal space, as determined mainly by the layout mode that is used. If the values of `margin-left` and `margin-right` are both `auto`, the calculated space is evenly distributed. This table summarizes the different cases: <table class="standard-table"> <thead> <tr> <th scope="col">Value of {{cssxref("display")}}</th> <th scope="col">Value of {{cssxref("float")}}</th> <th scope="col">Value of {{cssxref("position")}}</th> <th scope="col">Computed value of <code>auto</code></th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr> <th> <code>inline</code>, <code>inline-block</code>, <code>inline-table</code> </th> <th><em>any</em></th> <th><code>static</code> or <code>relative</code></th> <td><code>0</code></td> <td>Inline layout mode</td> </tr> <tr> <th> <code>block</code>, <code>inline</code>, <code>inline-block</code>, <code>block</code>, <code>table</code>, <code>inline-table</code>, <code>list-item</code>, <code>table-caption</code> </th> <th><em>any</em></th> <th><code>static</code> or <code>relative</code></th> <td> <code>0</code>, except if both <code>margin-left</code> and <code>margin-right</code> are set to <code>auto</code>. In this case, it is set to the value centering the element inside its parent. </td> <td>Block layout mode</td> </tr> <tr> <th> <code>block</code>, <code>inline</code>, <code>inline-block</code>, <code>block</code>, <code>table</code>, <code>inline-table</code>, <code>list-item</code>, <code>table-caption</code> </th> <th><code>left</code> or <code>right</code></th> <th><code>static</code> or <code>relative</code></th> <td><code>0</code></td> <td>Block layout mode (floating element)</td> </tr> <tr> <th> <em>any </em><code>table-*</code><em>, except </em ><code>table-caption</code> </th> <th><em>any</em></th> <th><em>any</em></th> <td><code>0</code></td> <td> Internal <code>table-*</code> elements don't have margins, use {{ cssxref("border-spacing") }} instead </td> </tr> <tr> <th> <em>any, except <code>flex</code>,</em> <code>inline-flex</code ><em>, or </em><code>table-*</code> </th> <th><em>any</em></th> <th> <em><code>fixed</code></em> or <code>absolute</code> </th> <td> <code>0</code>, except if both <code>margin-left</code> and <code>margin-right</code> are set to <code>auto</code>. In this case, it is set to the value centering the border area inside the available <code>width</code>, if fixed. </td> <td>Absolutely positioned layout mode</td> </tr> <tr> <th><code>flex</code>, <code>inline-flex</code></th> <th><em>any</em></th> <th><em>any</em></th> <td> <code>0</code>, except if there is any positive horizontal free space. In this case, it is evenly distributed to all horizontal <code>auto</code> margins. </td> <td>Flexbox layout mode</td> </tr> </tbody> </table> ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Setting right margin using pixels and percentages ```css .content { margin-right: 5%; } .sidebox { margin-right: 10px; } .logo { margin-right: -5px; } ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref("margin-top")}}, {{cssxref("margin-bottom")}}, and {{cssxref("margin-left")}} and the {{cssxref("margin")}} shorthand - The mapped logical properties: {{cssxref("margin-block-start")}}, {{cssxref("margin-block-end")}}, {{cssxref("margin-inline-start")}}, and {{cssxref("margin-inline-end")}} and the shorthands {{cssxref("margin-block")}} and {{cssxref("margin-inline")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_colon_-moz-only-whitespace/index.md
--- title: ":-moz-only-whitespace" slug: Web/CSS/:-moz-only-whitespace page-type: css-pseudo-class status: - non-standard browser-compat: css.selectors.-moz-only-whitespace --- {{CSSRef}}{{Non-standard_header}} > **Note:** In [Selectors Level 4](https://drafts.csswg.org/selectors-4/#the-empty-pseudo), the {{CSSxRef(":empty")}} selector was changed to act like `:-moz-only-whitespace`, but no browser currently supports this yet. The **`:-moz-only-whitespace`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) matches elements that only contain text nodes that only contain {{Glossary("whitespace")}}. (This includes elements with empty text nodes and elements with no child nodes.) ## Syntax ```css :-moz-only-whitespace { /* ... */ } ``` ## Examples ### Simple :-moz-only-whitespace example #### HTML ```html-nolint <div> </div> ``` #### CSS ```css div { border: 4px solid red; } :-moz-only-whitespace { border-color: lime; } ``` #### Result {{EmbedLiveSample('Simple_-moz-only-whitespace_example', '100%', 50)}} ## Specifications Briefly defined as `:blank` in [Selectors Level 4](https://drafts.csswg.org/selectors-4/#changes-2018-02), but then the functionality was merged into {{CSSxRef(":empty")}} and {{CSSxRef(":blank")}} redefined to mean empty {{HTMLElement("input")}}. ## Browser compatibility {{Compat}} ## See also - {{CSSxRef(":blank")}} {{Experimental_Inline}} - {{CSSxRef(":empty")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/margin-bottom/index.md
--- title: margin-bottom slug: Web/CSS/margin-bottom page-type: css-property browser-compat: css.properties.margin-bottom --- {{CSSRef}} The **`margin-bottom`** [CSS](/en-US/docs/Web/CSS) property sets the [margin area](/en-US/docs/Web/CSS/CSS_box_model/Introduction_to_the_CSS_box_model#margin_area) on the bottom of an element. A positive value places it farther from its neighbors, while a negative value places it closer. {{EmbedInteractiveExample("pages/css/margin-bottom.html")}} ![The effect of the CSS margin-bottom property on the element box](margin-bottom.svg) This property has no effect on _non-[replaced](/en-US/docs/Web/CSS/Replaced_element)_ inline elements, such as {{HTMLElement("span")}} or {{HTMLElement("code")}}. ## Syntax ```css /* <length> values */ margin-bottom: 10px; /* An absolute length */ margin-bottom: 1em; /* relative to the text size */ margin-bottom: 5%; /* relative to the nearest block container's width */ /* Keyword values */ margin-bottom: auto; /* Global values */ margin-bottom: inherit; margin-bottom: initial; margin-bottom: revert; margin-bottom: revert-layer; margin-bottom: unset; ``` The `margin-bottom` property is specified as the keyword `auto`, or a `<length>`, or a `<percentage>`. Its value can be positive, zero, or negative. ### Values - {{cssxref("&lt;length&gt;")}} - : The size of the margin as a fixed value. - {{cssxref("&lt;percentage&gt;")}} - : The size of the margin as a percentage, relative to the inline size (_width_ in a horizontal language, defined by {{cssxref("writing-mode")}}) of the [containing block](/en-US/docs/Web/CSS/Containing_block). - `auto` - : The browser selects a suitable value to use. See {{cssxref("margin")}}. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Setting positive and negative bottom margins #### HTML ```html <div class="container"> <div class="box0">Box 0</div> <div class="box1">Box 1</div> <div class="box2">Box one's negative margin pulls me up</div> </div> ``` #### CSS CSS for divs to set margin-bottom and height ```css .box0 { margin-bottom: 1em; height: 3em; } .box1 { margin-bottom: -1.5em; height: 4em; } .box2 { border: 1px dashed black; border-width: 1px 0; margin-bottom: 2em; } ``` Some definitions for container and divs so margins' effects can be seen more clearly ```css .container { background-color: orange; width: 320px; border: 1px solid black; } div { width: 320px; background-color: gold; } ``` #### Result {{ EmbedLiveSample('Setting_positive_and_negative_bottom_margins',350,200) }} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref("margin-top")}}, {{cssxref("margin-right")}}, and {{cssxref("margin-left")}} and the {{cssxref("margin")}} shorthand - The mapped logical properties: {{cssxref("margin-block-start")}}, {{cssxref("margin-block-end")}}, {{cssxref("margin-inline-start")}}, and {{cssxref("margin-inline-end")}} and the shorthands {{cssxref("margin-block")}} and {{cssxref("margin-inline")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/margin-bottom/margin-bottom.svg
<svg baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="400" height="130"><defs><pattern id="a" patternUnits="userSpaceOnUse" x="0" y="0" width="105" height="105"><path d="m0 90 15 15M0 75l30 30M0 60l45 45M0 45l60 60M0 30l75 75M0 15l90 90M0 0l105 105M15 0l90 90M30 0l75 75M45 0l60 60M60 0l45 45M75 0l30 30M90 0l15 15"/></pattern></defs><path fill="azure" d="M130 10h140v90H130z"/><path stroke="#000" stroke-dasharray="3 2" fill="#fff" d="M150 30h100v50H150z"/><path fill="beige" d="M160 40h80v30h-80z"/><text x="290" y="25" font-family="sans-serif" font-size="10pt">Margin area</text><path stroke="#000" d="M288 20h-53"/><text x="290" y="48" font-family="sans-serif" font-size="10pt">Border</text><path stroke="#000" d="M278 43h-28"/><text x="290" y="71" font-family="sans-serif" font-size="10pt">Content area</text><path stroke="#000" d="m288 67-58-7"/><text x="290" y="94" font-family="sans-serif" font-size="10pt">Padding area</text><path stroke="#000" d="m288 91-53-16"/><path fill="url(#a)" stroke="#000" d="M130 80h140v20H130z"/><path stroke="#000" d="M200 90v25"/><text x="42" y="125" font-family="sans-serif" font-size="10pt">The height of this area is defined by the margin-bottom value</text><path stroke="#000" d="M116 100h8m-8-20h8m-4 0v20"/><text x="10" y="93" font-family="'courier new',monospace" font-size="10pt">margin-bottom</text></svg>
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/mask-border-mode/index.md
--- title: mask-border-mode slug: Web/CSS/mask-border-mode page-type: css-property spec-urls: https://drafts.fxtf.org/css-masking-1/#the-mask-border-mode --- {{CSSRef}} The **`mask-border-mode`** [CSS](/en-US/docs/Web/CSS) property specifies the blending mode used in a [mask border](/en-US/docs/Web/CSS/mask-border). ## Syntax ```css /* Keyword values */ mask-border-mode: luminance; mask-border-mode: alpha; /* Global values */ mask-border-mode: inherit; mask-border-mode: initial; mask-border-mode: revert; mask-border-mode: revert-layer; mask-border-mode: unset; ``` ### Values - `luminance` - : The luminance values of the mask border image are used as the mask values. - `alpha` - : The alpha values of the mask border image are used as the mask values. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Specifications {{Specifications}} ## Browser compatibility This property is not supported by any browser yet. ## See also - {{cssxref("mask-border")}} - {{cssxref("mask-border-outset")}} - {{cssxref("mask-border-repeat")}} - {{cssxref("mask-border-source")}} - {{cssxref("mask-border-width")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/-webkit-overflow-scrolling/index.md
--- title: "-webkit-overflow-scrolling" slug: Web/CSS/-webkit-overflow-scrolling page-type: css-property status: - non-standard browser-compat: css.properties.-webkit-overflow-scrolling --- {{CSSRef}} {{Non-standard_header}} The `-webkit-overflow-scrolling` [CSS](/en-US/docs/Web/CSS) property controls whether or not touch devices use momentum-based scrolling for a given element. ## Syntax ```css /* Keyword values */ -webkit-overflow-scrolling: auto; -webkit-overflow-scrolling: touch; /* Global values */ -webkit-overflow-scrolling: inherit; -webkit-overflow-scrolling: initial; -webkit-overflow-scrolling: revert; -webkit-overflow-scrolling: revert-layer; -webkit-overflow-scrolling: unset; ``` ### Values - `auto` - : Use "regular" scrolling, where the content immediately ceases to scroll when you remove your finger from the touchscreen. - `touch` - : Use momentum-based scrolling, where the content continues to scroll for a while after finishing the scroll gesture and removing your finger from the touchscreen. The speed and duration of the continued scrolling is proportional to how vigorous the scroll gesture was. Also creates a new stacking context. ## Formal definition {{CSSInfo}} ## Formal syntax ```plain -webkit-overflow-scrolling = auto | touch ``` ## Examples ### HTML ```html <div class="scroll-touch"> <p>This paragraph has momentum scrolling</p> </div> <div class="scroll-auto"> <p>This paragraph does not.</p> </div> ``` ### CSS ```css div { width: 100%; overflow: auto; } p { width: 200%; background: #f5f9fa; border: 2px solid #eaf2f4; padding: 10px; } .scroll-touch { -webkit-overflow-scrolling: touch; /* Lets it scroll lazy */ } .scroll-auto { -webkit-overflow-scrolling: auto; /* Stops scrolling immediately */ } ``` ### Results {{EmbedLiveSample('Examples')}} ## Specifications Not part of any standard. Apple has [a description in the Safari CSS Reference](https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariCSSRef/Articles/StandardCSSProperties.html#//apple_ref/css/property/-webkit-overflow-scrolling). ## Browser compatibility {{Compat}} ## See also - [CSS-Tricks article with demo](https://css-tricks.com/snippets/css/momentum-scrolling-on-ios-overflow-elements/) - [Smashing Magazine - describing the effect of scroll bouncing and how it works on different web browsers](https://www.smashingmagazine.com/2018/08/scroll-bouncing-websites/) - [Safari 13 Release notes](https://developer.apple.com/documentation/safari-release-notes/safari-13-release-notes): Indicates the addition of support for one-finger accelerated scrolling to all frames and `overflow:scroll` elements, eliminating the need to set `-webkit-overflow-scrolling: touch`.
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_colon_stalled/index.md
--- title: ":stalled" slug: Web/CSS/:stalled page-type: css-pseudo-class browser-compat: css.selectors.stalled --- {{CSSRef}} The **`:stalled`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) selector represents an element that is playable, such as {{htmlelement("audio")}} or {{htmlelement("video")}}, when playback is stalled. A resource is considered to be stalled if the user has requested playback of a specific position in the media resource, but it has failed to receive any data for some amount of time. This is different from {{cssxref(":buffering")}} in that the media element is unexpectedly not loading data when stalled (e.g. due to a network error) for around 3 seconds (the exact time is [user agent dependent](https://html.spec.whatwg.org/multipage/media.html#stall-timeout)). > **Note:** Like with the {{cssxref(":buffering")}} pseudo-class, the element is still considered to be "playing" when it is "stalled". > If `:stalled` matches an element, {{cssxref(":playing")}} will also match that element. ## Syntax ```css :stalled { /* ... */ } ``` ## Examples ### CSS ```css :stalled { outline: 5px solid red; } audio:stalled { background-color: red; } ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref(":buffering")}} - {{cssxref(":muted")}} - {{cssxref(":paused")}} - {{cssxref(":playing")}} - {{cssxref(":seeking")}} - {{cssxref(":volume-locked")}} - [CSS selectors](/en-US/docs/Web/CSS/CSS_selectors) - [`stalled`](/en-US/docs/Web/API/HTMLMediaElement/stalled_event) event
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/max/index.md
--- title: max() slug: Web/CSS/max page-type: css-function browser-compat: css.types.max --- {{CSSRef}} The **`max()`** [CSS](/en-US/docs/Web/CSS) [function](/en-US/docs/Web/CSS/CSS_Functions) lets you set the largest (most positive) value from a list of comma-separated expressions as the value of a CSS property value. The `max()` function can be used anywhere a {{CSSxRef("&lt;length&gt;")}}, {{CSSxRef("&lt;frequency&gt;")}}, {{CSSxRef("&lt;angle&gt;")}}, {{CSSxRef("&lt;time&gt;")}}, {{CSSxRef("&lt;percentage&gt;")}}, {{CSSxRef("&lt;number&gt;")}}, or {{CSSxRef("&lt;integer&gt;")}} is allowed. {{EmbedInteractiveExample("pages/css/function-max.html")}} In the first example shown above, the width will be at least 400px, but will be wider if the viewport is more than 2000px wide (in which case 1vw would be 20px, so 20vw would be 400px). This technique uses an absolute unit to specify a fixed minimum value for the property, and a relative unit to allow the value to grow to suit larger viewports. ## Syntax The `max()` function takes one or more comma-separated expressions as its parameter, with the largest (most positive) expression value used as the value of the property to which it is assigned. The expressions can be math expressions (using arithmetic operators), literal values, or other expressions, such as {{CSSxRef("attr", "attr()")}}, that evaluate to a valid argument type (like {{CSSxRef("&lt;length&gt;")}}), or nested {{CSSxRef("min", "min()")}} and `max()` functions. You can use different units for each value in your expression. You may also use parentheses to establish computation order when needed. ### Notes - Math expressions involving percentages for widths and heights on table columns, table column groups, table rows, table row groups, and table cells in both auto and fixed layout tables _may_ be treated as if `auto` had been specified. - It is permitted to nest `min()` and other `max()` functions as expression values. The expressions are full math expressions, so you can use direct addition, subtraction, multiplication and division without using the calc() function itself. - The expression can be values combining the addition ( + ), subtraction ( - ), multiplication ( \* ) and division ( / ) operators, using standard operator precedence rules. Make sure to put a space on each side of the + and - operands. The operands in the expression may be any \<length> syntax value. - You can (and often need to) combine `min()` and `max()` values, or use `max()` within a `clamp()` or `calc()` function. ### Formal syntax {{CSSSyntax}} ## Examples ### Setting a minimum size for a font Another use case for `max()` is to allow a font size to grow while ensuring it is at least a minimum size, enabling responsive font sizes while ensuring legibility. Let's look at some CSS: ```css h1 { font-size: 2rem; } h1.responsive { font-size: max(4vw, 2em, 2rem); } ``` The font-size will at minimum be 2rems, or twice the default size of font for the page. This ensures that it is legible and accessible. ```html <h1>This text is always legible, but doesn't change size</h1> <h1 class="responsive"> This text is always legible, and is responsive, to a point </h1> ``` {{EmbedLiveSample("Setting_a_minimum_size_for_a_font", "100%", "300")}} Think of the `max()` function as finding the minimum value allowed for a property. ## Accessibility concerns When `max()` is used for controlling text size, make sure the text is always large enough to read. A suggestion is to use the {{CSSxRef("min", "min()")}} function nested within a `max()` that has as its second value a [relative length unit](/en-US/docs/Web/CSS/length#relative_length_units) that is always large enough to read. For example: ```css small { font-size: max(min(0.5vw, 0.5em), 1rem); } ``` This ensures a minimum size of _1rem_, with a text size that scales if the page is zoomed. - [MDN Understanding WCAG, Guideline 1.4 explanations](/en-US/docs/Web/Accessibility/Understanding_WCAG/Perceivable#guideline_1.4_make_it_easier_for_users_to_see_and_hear_content_including_separating_foreground_from_background) - [Understanding Success Criterion 1.4.4 | W3C Understanding WCAG 2.0](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-scale.html) ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{CSSxRef("calc", "calc()")}} - {{CSSxRef("clamp", "clamp()")}} - {{CSSxRef("min", "min()")}} - [CSS Values](/en-US/docs/Learn/CSS/Building_blocks/Values_and_units)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/font-variant/index.md
--- title: font-variant slug: Web/CSS/font-variant page-type: css-shorthand-property browser-compat: css.properties.font-variant --- {{CSSRef}} The **`font-variant`** CSS [shorthand property](/en-US/docs/Web/CSS/Shorthand_properties) allows you to set all the font variants for a font. You can also set the `<font-variant-css2>` values of `font-variant` defined in CSS Level 2.1, (that is, `normal` or `small-caps`), by using the [`font`](/en-US/docs/Web/CSS/font) shorthand. {{EmbedInteractiveExample("pages/css/font-variant.html")}} ## Constituent properties This property is a shorthand for the following CSS properties: - [`font-variant-alternates`](/en-US/docs/Web/CSS/font-variant-alternates) - [`font-variant-caps`](/en-US/docs/Web/CSS/font-variant-caps) - [`font-variant-east-asian`](/en-US/docs/Web/CSS/font-variant-east-asian) - [`font-variant-emoji`](/en-US/docs/Web/CSS/font-variant-emoji) - [`font-variant-ligatures`](/en-US/docs/Web/CSS/font-variant-ligatures) - [`font-variant-numeric`](/en-US/docs/Web/CSS/font-variant-numeric) - [`font-variant-position`](/en-US/docs/Web/CSS/font-variant-position) ## Syntax ```css font-variant: small-caps; font-variant: common-ligatures small-caps; /* Global values */ font-variant: inherit; font-variant: initial; font-variant: revert; font-variant: revert-layer; font-variant: unset; ``` ### Values - `normal` - : Specifies a normal font face. Each longhand property has an initial value of `normal`. - `none` - : Sets the value of the [`font-variant-ligatures`](/en-US/docs/Web/CSS/font-variant-ligatures) as `none` and the values of the other longhand properties as `normal`, their initial value. - `<common-lig-values>`, `<discretionary-lig-values>`, `<historical-lig-values>`, `<contextual-alt-values>` - : Specifies the keywords related to the [`font-variant-ligatures`](/en-US/docs/Web/CSS/font-variant-ligatures) longhand property. The possible values are `common-ligatures`, `no-common-ligatures`, `discretionary-ligatures`, `no-discretionary-ligatures`, `historical-ligatures`, `no-historical-ligatures`, `contextual`, and `no-contextual`. - `stylistic()`, `historical-forms`, `styleset()`, `character-variant()`, `swash()`, `ornaments()`, `annotation()` - : Specifies the keywords and functions related to the [`font-variant-ligatures`](/en-US/docs/Web/CSS/font-variant-ligatures) longhand property. - `small-caps`, `all-small-caps`, `petite-caps`, `all-petite-caps`, `unicase`, `titling-caps` - : Specifies the keywords and functions related to the [`font-variant-caps`](/en-US/docs/Web/CSS/font-variant-caps) longhand property. The `small-caps` value is the only non-`normal` font variant valid within the {{cssxref("font")}} shorthand property. - `<numeric-figure-values>`, `<numeric-spacing-values>`, `<numeric-fraction-values>`, `ordinal`, `slashed-zero` - : Specifies the keywords related to the [`font-variant-numeric`](/en-US/docs/Web/CSS/font-variant-numeric) longhand property. The possible values are `lining-nums`, `oldstyle-nums`, `proportional-nums`, `tabular-nums`, `diagonal-fractions`, `stacked-fractions`, `ordinal`, and `slashed-zero`. - `<east-asian-variant-values>`, `<east-asian-width-values>`, `ruby` - : Specifies the keywords related to the [`font-variant-east-asian`](/en-US/docs/Web/CSS/font-variant-east-asian) longhand property. The possible values are `jis78`, `jis83`, `jis90`, `jis04`, `simplified`, `traditional`, `full-width`, `proportional-width`, and `ruby`. - `sub`, `super` - : Specifies the keywords and functions related to the [`font-variant-position`](/en-US/docs/Web/CSS/font-variant-position) longhand property. - `text`, `emoji`, `unicode` - : Specifies the keywords and functions related to the [`font-variant-emoji`](/en-US/docs/Web/CSS/font-variant-emoji) longhand property. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Setting the small-caps font variant #### HTML ```html <p class="normal">Firefox rocks!</p> <p class="small">Firefox rocks!</p> ``` #### CSS ```css p.normal { font-variant: normal; } p.small { font-variant: small-caps; } ``` #### Result {{ EmbedLiveSample('Setting the small-caps font variant') }} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [`text-transform`](/en-US/docs/Web/CSS/text-transform) - [`text-combine-upright`](/en-US/docs/Web/CSS/text-combine-upright) - [`text-orientation`](/en-US/docs/Web/CSS/text-orientation)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/descendant_combinator/index.md
--- title: Descendant combinator slug: Web/CSS/Descendant_combinator page-type: css-combinator browser-compat: css.selectors.descendant --- {{CSSRef}} The **descendant combinator** — typically represented by a single space (" ") character — combines two selectors such that elements matched by the second selector are selected if they have an ancestor (parent, parent's parent, parent's parent's parent, etc.) element matching the first selector. Selectors that utilize a descendant combinator are called _descendant selectors_. ```css /* List items that are descendants of the "my-things" list */ ul.my-things li { margin: 2em; } ``` The descendant combinator is technically one or more {{Glossary("CSS")}} white space characters — the space character and/or one of four control characters: carriage return, form feed, new line, and tab characters — between two selectors in the absence of another combinator. Additionally, the white space characters of which the combinator is comprised may contain any number of CSS comments. ## Syntax ```css selector1 selector2 { /* property declarations */ } ``` ## Examples ### CSS ```css li { list-style-type: disc; } li li { list-style-type: circle; } ``` ### HTML ```html <ul> <li> <div>Item 1</div> <ul> <li>Subitem A</li> <li>Subitem B</li> </ul> </li> <li> <div>Item 2</div> <ul> <li>Subitem A</li> <li>Subitem B</li> </ul> </li> </ul> ``` ### Result {{EmbedLiveSample("Examples", "100%", 160)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Child combinator](/en-US/docs/Web/CSS/Child_combinator)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/padding-top/index.md
--- title: padding-top slug: Web/CSS/padding-top page-type: css-property browser-compat: css.properties.padding-top --- {{CSSRef}} The **`padding-top`** [CSS](/en-US/docs/Web/CSS) property sets the height of the [padding area](/en-US/docs/Web/CSS/CSS_box_model/Introduction_to_the_CSS_box_model#padding_area) on the top of an element. {{EmbedInteractiveExample("pages/css/padding-top.html")}} An element's padding area is the space between its content and its border. ![The effect of the CSS padding-top property on the element box](padding-top.svg) > **Note:** The {{cssxref("padding")}} property can be used to set paddings on all four sides of an element with a single declaration. ## Syntax ```css /* <length> values */ padding-top: 0.5em; padding-top: 0; padding-top: 2cm; /* <percentage> value */ padding-top: 10%; /* Global values */ padding-top: inherit; padding-top: initial; padding-top: revert; padding-top: revert-layer; padding-top: unset; ``` The `padding-top` property is specified as a single value chosen from the list below. Unlike margins, negative values are not allowed for padding. ### Values - {{cssxref("&lt;length&gt;")}} - : The size of the padding as a fixed value. Must be nonnegative. - {{cssxref("&lt;percentage&gt;")}} - : The size of the padding as a percentage, relative to the inline size (_width_ in a horizontal language, defined by {{cssxref("writing-mode")}}) of the [containing block](/en-US/docs/Web/CSS/Containing_block). Must be nonnegative. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Setting top padding using pixels and percentages ```css .content { padding-top: 5%; } .sidebox { padding-top: 10px; } ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Introduction to the CSS basic box model](/en-US/docs/Web/CSS/CSS_box_model/Introduction_to_the_CSS_box_model) - {{cssxref("padding-right")}}, {{cssxref("padding-bottom")}}, {{cssxref("padding-left")}} and the {{cssxref("padding")}} shorthand - The mapped logical properties: {{cssxref("padding-block-start")}}, {{cssxref("padding-block-end")}}, {{cssxref("padding-inline-start")}}, and {{cssxref("padding-inline-end")}} and the shorthands {{cssxref("padding-block")}} and {{cssxref("padding-inline")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/padding-top/padding-top.svg
<svg baseProfile="full" xmlns="http://www.w3.org/2000/svg" width="400" height="130"><defs><pattern id="a" patternUnits="userSpaceOnUse" x="0" y="0" width="105" height="105"><path d="m0 90 15 15M0 75l30 30M0 60l45 45M0 45l60 60M0 30l75 75M0 15l90 90M0 0l105 105M15 0l90 90M30 0l75 75M45 0l60 60M60 0l45 45M75 0l30 30M90 0l15 15"/></pattern></defs><path fill="azure" d="M130 40h140v90H130z"/><path stroke="#000" stroke-dasharray="3 2" fill="#fff" d="M150 60h100v50H150z"/><path fill="beige" d="M160 70h80v30h-80z"/><text x="290" y="124" font-family="sans-serif" font-size="10pt">Padding area</text><path stroke="#000" d="m288 120-53-15"/><text x="290" y="78" font-family="sans-serif" font-size="10pt">Border</text><path stroke="#000" d="M278 74h-28"/><text x="290" y="101" font-family="sans-serif" font-size="10pt">Content area</text><path stroke="#000" d="m288 97-58-7"/><text x="290" y="55" font-family="sans-serif" font-size="10pt">Margin area</text><path stroke="#000" d="M288 50h-53"/><path fill="url(#a)" stroke="#000" d="M150 60h100v10H150z"/><path stroke="#000" d="M200 27v40"/><text x="42" y="20" font-family="sans-serif" font-size="10pt">The height of this area is defined by the padding-top value</text><path stroke="#000" d="M136 60h8m-8 10h8m-4-10v10"/><text x="35" y="67" font-family="'courier new',monospace" font-size="10pt">padding-top</text></svg>
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/_colon_host_function/index.md
--- title: ":host()" slug: Web/CSS/:host_function page-type: css-pseudo-class browser-compat: css.selectors.hostfunction --- {{CSSRef}} The **`:host()`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) function selects the shadow host of the [shadow DOM](/en-US/docs/Web/API/Web_components/Using_shadow_DOM) containing the CSS it is used inside (so you can select a custom element from inside its shadow DOM) — but only if the selector given as the function's parameter matches the shadow host. **`:host()`** has no effect when used outside a shadow DOM. The most obvious use of this is to put a class name only on certain custom element instances, and then include the relevant class selector as the function argument. You can't use this with a descendant selector expression to select only instances of the custom element that are inside a particular ancestor. That's the job of {{CSSxRef(":host-context", ":host-context()")}}. > **Note:** While other functional pseudo-classes such as {{CSSxRef(":is", ":is()")}} and {{CSSxRef(":not", ":not()")}} accept a list of selectors as their parameters, `:host()` takes a single compound selector as its parameter. In addition, while `:is()` and `:not()` only take into account the specificity of their argument, the specificity of `:host()` is both the specificity of the pseudo-class **and** the specificity of its argument. {{EmbedInteractiveExample("pages/tabbed/pseudo-class-host_function.html", "tabbed-shorter")}} ```css /* Selects a shadow root host, only if it is matched by the selector argument */ :host(.special-custom-element) { font-weight: bold; } ``` ## Syntax ```css-nolint :host(<compound-selector>) { /* ... */ } ``` ## Examples ### Selectively styling shadow hosts The following snippets are taken from our [host-selectors example](https://github.com/mdn/web-components-examples/tree/main/host-selectors) ([see it live also](https://mdn.github.io/web-components-examples/host-selectors/)). In this example we have a simple custom element — `<context-span>` — that you can wrap around text: ```html <h1> Host selectors <a href="#"><context-span>example</context-span></a> </h1> ``` Inside the element's constructor, we create `style` and `span` elements, fill the `span` with the content of the custom element, and fill the `style` element with some CSS rules: ```js const style = document.createElement("style"); const span = document.createElement("span"); span.textContent = this.textContent; const shadowRoot = this.attachShadow({ mode: "open" }); shadowRoot.appendChild(style); shadowRoot.appendChild(span); style.textContent = "span:hover { text-decoration: underline; }" + ":host-context(h1) { font-style: italic; }" + ':host-context(h1):after { content: " - no links in headers!" }' + ":host-context(article, aside) { color: gray; }" + ":host(.footer) { color : red; }" + ":host { background: rgb(0 0 0 / 10%); padding: 2px 5px; }"; ``` The `:host(.footer) { color : red; }` rule styles all instances of the `<context-span>` element (the shadow host in this instance) in the document that have the `footer` class set on them — we've used it to give instances of the element inside the {{htmlelement("footer")}} a special color. ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Web components](/en-US/docs/Web/API/Web_components) - {{CSSxRef(":host")}} - {{CSSxRef(":host-context", ":host-context()")}} - {{CSSxRef(":state",":state()")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/filter/index.md
--- title: filter slug: Web/CSS/filter page-type: css-property browser-compat: css.properties.filter --- {{CSSRef}} The **`filter`** [CSS](/en-US/docs/Web/CSS) property applies graphical effects like blur or color shift to an element. Filters are commonly used to adjust the rendering of images, backgrounds, and borders. Several [functions](#functions), such as `blur()` and `contrast()`, are available to help you achieve predefined effects. {{EmbedInteractiveExample("pages/css/filter.html")}} ## Syntax ```css /* <filter-function> values */ filter: blur(5px); filter: brightness(0.4); filter: contrast(200%); filter: drop-shadow(16px 16px 20px blue); filter: grayscale(50%); filter: hue-rotate(90deg); filter: invert(75%); filter: opacity(25%); filter: saturate(30%); filter: sepia(60%); /* URL */ filter: url("filters.svg#filter-id"); /* Multiple filters */ filter: contrast(175%) brightness(3%); filter: drop-shadow(3px 3px red) sepia(100%) drop-shadow(-3px -3px blue); /* Use no filter */ filter: none; /* Global values */ filter: inherit; filter: initial; filter: revert; filter: revert-layer; filter: unset; ``` With a function, use the following: ```css-nolint filter: <filter-function> [<filter-function>]* | none; ``` You can use `url()` to reference an [SVG filter element](/en-US/docs/Web/SVG/Element/filter). For a reference to an SVG {{SVGElement("filter")}} element, use the following syntax: ```css filter: url(file.svg#filter-element-id); ``` ## Functions The `filter` property is specified as `none` or one or more of the functions listed below. If the parameter for any function is invalid, the function returns `none`. Except where noted, the functions that take a value expressed with a percent sign (as in `34%`) also accept the value expressed as decimal (as in `0.34`). When the `filter` property values contains multiple functions, the filters are applied in order. - {{cssxref("filter-function/blur", "blur()")}} - : Applies a Gaussian blur to the input image. ```css filter: blur(5px); ``` - {{cssxref("filter-function/brightness", "brightness()")}} - : Applies a linear multiplier to the input image, making it appear more or less bright. Values are linear multipliers on the effect, with `0%` creating a completely black image, `100%` having no effect, and values over `100%` brightening the image. ```css filter: brightness(2); ``` - {{cssxref("filter-function/contrast", "contrast()")}} - : Adjusts the contrast of the input image. A value of `0%` makes the image grey, `100%` has no effect, and values over `100%` create a contrast. ```css filter: contrast(200%); ``` - {{cssxref("filter-function/drop-shadow", "drop-shadow()")}} - : Applies the parameter `<shadow>` as a drop shadow, following the contours of the image. The shadow syntax is similar to `<box-shadow>` (defined in the [CSS backgrounds and borders module](/en-US/docs/Web/CSS/CSS_backgrounds_and_borders)), with the exception that the `inset` keyword and `spread` parameter are not allowed. As with all `filter` property values, any filters after the `drop-shadow()` are applied to the shadow. ```css filter: drop-shadow(16px 16px 10px black); ``` - {{cssxref("filter-function/grayscale", "grayscale()")}} - : Converts the image to grayscale. A value of `100%` is completely grayscale. The initial value of `0%` leaves the input unchanged. Values between `0%` and `100%` produce linear multipliers on the effect. ```css filter: grayscale(100%); ``` - {{cssxref("filter-function/hue-rotate", "hue-rotate()")}} - : Applies a hue rotation. The `<angle>` value defines the number of degrees around the hue color circle at which the input samples will be adjusted. A value of `0deg` leaves the input unchanged. ```css filter: hue-rotate(90deg); ``` - {{cssxref("filter-function/invert", "invert()")}} - : Inverts the samples in the input image. A value of `100%` completely inverts the image. A value of `0%` leaves the input unchanged. Values between `0%` and `100%` have linear multipliers on the effect. ```css filter: invert(100%); ``` - {{cssxref("filter-function/opacity", "opacity()")}} - : Applies transparency. `0%` makes the image completely transparent and `100%` leaves the image unchanged. ```css filter: opacity(50%); ``` - {{cssxref("filter-function/saturate", "saturate()")}} - : Saturates the image, with `0%` being completely unsaturated, `100%` leaving the image unchanged, and values of over `100%` increasing saturation. ```css filter: saturate(200%); ``` - {{cssxref("filter-function/sepia", "sepia()")}} - : Converts the image to sepia, with a value of `100%` making the image completely sepia and `0%` making no change. ```css filter: sepia(100%); ``` ## Combining functions You may combine any number of functions to manipulate the rendering. The filters are applied in the order declared. The following example enhances the contrast and brightness of the image: ```css filter: contrast(175%) brightness(103%); ``` ### Interpolation When animated, if both the beginning and end filters have a function list of the same length without {{cssxref("url","url()")}} in the same order, each of their filter functions is {{Glossary("interpolation", "interpolated")}} according to the filter function's specific rules. If the filter lists are of different lengths, the missing equivalent filter functions from the longer list are added to the end of the shorter list. The added functions use their initial, no filter modification values. All the filters listed are then interpolated according to the filter function's specific rules. Otherwise, discrete interpolation is used. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Applying filter functions The `filter` property is applied to the second image, greying and blurring both the image and its border. ```css img { border: 5px solid yellow; } /* Gray the second image by 40% and blur by 5px */ img:nth-of-type(2) { filter: grayscale(0.4) blur(5px); } ``` ```html <img src="pencil.jpg" alt="Original image is sharp" /> <img src="pencil.jpg" alt="The image and border are blurred and muted" /> ``` {{EmbedLiveSample('Applying_filter_functions','100%','229px')}} ### Repeating filter functions Filter functions are applied in order of appearance. The same filter function can be repeated. ```css #MDN-logo { border: 1px solid blue; filter: drop-shadow(5px 5px 0 red) hue-rotate(180deg) drop-shadow(5px 5px 0 red); } ``` ```html hidden <svg id="MDN-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 361 104.2" xml:space="preserve" role="img"> <title>MDN Web Docs</title> <path d="M197.6 73.2h-17.1v-5.5h3.8V51.9c0-3.7-.7-6.3-2.1-7.9-1.4-1.6-3.3-2.3-5.7-2.3-3.2 0-5.6 1.1-7.2 3.4s-2.4 4.6-2.5 6.9v15.6h6v5.5h-17.1v-5.5h3.8V51.9c0-3.8-.7-6.4-2.1-7.9-1.4-1.5-3.3-2.3-5.6-2.3-3.2 0-5.5 1.1-7.2 3.3-1.6 2.2-2.4 4.5-2.5 6.9v15.8h6.9v5.5h-20.2v-5.5h6V42.4h-6.1v-5.6h13.4v6.4c1.2-2.1 2.7-3.8 4.7-5.2 2-1.3 4.4-2 7.3-2s5.3.7 7.5 2.1c2.2 1.4 3.7 3.5 4.5 6.4 1.1-2.5 2.7-4.5 4.9-6.1s4.8-2.4 7.9-2.4c3.5 0 6.5 1.1 8.9 3.3s3.7 5.6 3.7 10.2v18.2h6.1v5.5zm42.5 0h-13.2V66c-1.2 2.2-2.8 4.1-4.9 5.6-2.1 1.6-4.8 2.4-8.3 2.4-4.8 0-8.7-1.6-11.6-4.9-2.9-3.2-4.3-7.7-4.3-13.3 0-5 1.3-9.6 4-13.7 2.6-4.1 6.9-6.2 12.8-6.2s9.8 2.2 12.3 6.5V22.7h-8.6v-5.6h15.8v50.6h6v5.5zm-13.3-16.8V52c-.1-3-1.2-5.5-3.2-7.3s-4.4-2.8-7.2-2.8c-3.6 0-6.3 1.3-8.2 3.9-1.9 2.6-2.8 5.8-2.8 9.6 0 4.1 1 7.3 3 9.5s4.5 3.3 7.4 3.3c3.2 0 5.8-1.3 7.8-3.8 2.1-2.6 3.1-5.3 3.2-8zm61.5 16.8H269v-5.5h6V51.9c0-3.7-.7-6.3-2.2-7.9-1.4-1.6-3.4-2.3-5.7-2.3-3.1 0-5.6 1-7.4 3s-2.8 4.4-2.9 7v15.9h6v5.5h-19.3v-5.5h6V42.4h-6.2v-5.6h13.6V43c2.6-4.6 6.8-6.9 12.7-6.9 3.6 0 6.7 1.1 9.2 3.3s3.7 5.6 3.7 10.2v18.2h6v5.4h-.2z" style="fill: var(--text-primary);"></path> <g style="fill:blue;"> <path d="M42 .2 13.4 92.3H1.7L30.2.2H42zM52.4.2v92.1H42V.2h10.4zm40.3 0L64.2 92.3H52.5L81 .2h11.7zM103.1.2v92.1H92.7V.2h10.4zM294 95h67v8.8h-67V95z"></path> </g> </svg> ``` {{EmbedLiveSample('Repeating_filter_functions','100%','229px')}} The filters are applied in order. This is why the drop shadows are not the same color: the first drop shadow's hue is altered by the `hue-rotate()` function but the second one is not. ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - CSS {{cssxref("backdrop-filter")}} property - CSS [compositing and blending](/en-US/docs/Web/CSS/CSS_compositing_and_blending) module, including the CSS {{cssxref("background-blend-mode")}} and {{cssxref("mix-blend-mode")}} properties. - The CSS {{cssxref("mask")}} property - [SVG](/en-US/docs/Web/SVG), including the SVG {{SVGElement("filter")}} element and SVG {{SVGAttr("filter")}} attribute. - [Applying SVG effects to HTML content](/en-US/docs/Web/SVG/Applying_SVG_effects_to_HTML_content)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/animation-direction/index.md
--- title: animation-direction slug: Web/CSS/animation-direction page-type: css-property browser-compat: css.properties.animation-direction --- {{CSSRef}} The **`animation-direction`** [CSS](/en-US/docs/Web/CSS) property sets whether an animation should play forward, backward, or alternate back and forth between playing the sequence forward and backward. {{EmbedInteractiveExample("pages/css/animation-direction.html")}} It is often convenient to use the shorthand property {{cssxref("animation")}} to set all animation properties at once. ## Syntax ```css /* Single animation */ animation-direction: normal; animation-direction: reverse; animation-direction: alternate; animation-direction: alternate-reverse; /* Multiple animations */ animation-direction: normal, reverse; animation-direction: alternate, reverse, normal; /* Global values */ animation-direction: inherit; animation-direction: initial; animation-direction: revert; animation-direction: revert-layer; animation-direction: unset; ``` ### Values - `normal` - : The animation plays _forwards_ each cycle. In other words, each time the animation cycles, the animation will reset to the beginning state and start over again. This is the default value. - `reverse` - : The animation plays _backwards_ each cycle. In other words, each time the animation cycles, the animation will reset to the end state and start over again. Animation steps are performed backwards, and easing functions are also reversed. For example, an `ease-in` easing function becomes `ease-out`. - `alternate` - : The animation reverses direction each cycle, with the first iteration being played _forwards_. The count to determine if a cycle is even or odd starts at one. - `alternate-reverse` - : The animation reverses direction each cycle, with the first iteration being played _backwards_. The count to determine if a cycle is even or odd starts at one. > **Note:** When you specify multiple comma-separated values on an `animation-*` property, they are applied to the animations in the order in which the {{cssxref("animation-name")}}s appear. For situations where the number of animations and `animation-*` property values do not match, see [Setting multiple animation property values](/en-US/docs/Web/CSS/CSS_animations/Using_CSS_animations#setting_multiple_animation_property_values). > **Note:** When creating [CSS scroll-driven animations](/en-US/docs/Web/CSS/CSS_scroll-driven_animations), specifying an `animation-direction` works as expected, for example `reverse` causes the animation to run in reverse over the course of the timeline's progression. A value of `alternate` (combined with an {{cssxref("animation-iteration-count")}}) causes the animation to run forwards and backwards as the timeline is progressed. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Reversing the animation direction #### HTML ```html <div class="box"></div> ``` #### CSS ```css .box { background-color: rebeccapurple; border-radius: 10px; width: 100px; height: 100px; } .box:hover { animation-name: rotate; animation-duration: 0.7s; animation-direction: reverse; } @keyframes rotate { 0% { transform: rotate(0); } 100% { transform: rotate(360deg); } } ``` #### Result {{EmbedLiveSample("Reversing the animation direction","100%","250")}} See [CSS animations](/en-US/docs/Web/CSS/CSS_animations/Using_CSS_animations) for examples. ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Using CSS animations](/en-US/docs/Web/CSS/CSS_animations/Using_CSS_animations) - JavaScript {{domxref("AnimationEvent")}} API - Other related animation properties: {{cssxref("animation")}}, {{cssxref("animation-composition")}}, {{cssxref("animation-delay")}}, {{cssxref("animation-duration")}}, {{cssxref("animation-fill-mode")}}, {{cssxref("animation-iteration-count")}}, {{cssxref("animation-name")}}, {{cssxref("animation-play-state")}}, {{cssxref("animation-timeline")}}, {{cssxref("animation-timing-function")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/containing_block/index.md
--- title: Layout and the containing block slug: Web/CSS/Containing_block page-type: guide --- {{CSSRef}} The size and position of an element are often impacted by its **containing block**. Most often, the containing block is the [content area](/en-US/docs/Web/CSS/CSS_box_model/Introduction_to_the_CSS_box_model#content_area) of an element's nearest [block-level](/en-US/docs/Glossary/Block-level_content) ancestor, but this is not always the case. In this article, we examine the factors that determine an element's containing block. When a user agent (such as your browser) lays out a document, it generates a box for every element. Each box is divided into four areas: 1. Content area 2. Padding area 3. Border area 4. Margin area ![Diagram of the box model](box-model.png) Many developers believe that the containing block of an element is always the content area of its parent, but that isn't necessarily true. Let's investigate the factors that determine what an element's containing block is. ## Effects of the containing block Before learning what determines the containing block of an element, it's useful to know why it matters in the first place. The size and position of an element are often impacted by its containing block. Percentage values that are applied to the {{cssxref("width")}}, {{cssxref("height")}}, {{cssxref("padding")}}, {{cssxref("margin")}}, and offset properties of an absolutely positioned element (i.e., which has its {{cssxref("position")}} set to `absolute` or `fixed`) are computed from the element's containing block. ## Identifying the containing block The process for identifying the containing block depends entirely on the value of the element's {{cssxref("position")}} property: 1. If the `position` property is **`static`**, **`relative`**, or **`sticky`**, the containing block is formed by the edge of the _content box_ of the nearest ancestor element that is either **a block container** (such as an inline-block, block, or list-item element) or **establishes a formatting context** (such as a table container, flex container, grid container, or the block container itself). 2. If the `position` property is **`absolute`**, the containing block is formed by the edge of the _padding box_ of the nearest ancestor element that has a `position` value other than `static` (`fixed`, `absolute`, `relative`, or `sticky`). 3. If the `position` property is **`fixed`**, the containing block is established by the {{glossary("viewport")}} (in the case of continuous media) or the page area (in the case of paged media). 4. If the `position` property is **`absolute`** or **`fixed`**, the containing block may also be formed by the edge of the _padding box_ of the nearest ancestor element that has any of the following: 1. A {{cssxref("transform")}} or {{cssxref("perspective")}} value other than `none` 2. A {{cssxref("will-change")}} value of `transform` or `perspective` 3. A {{cssxref("filter")}} value other than `none` or a `will-change` value of `filter` (only works on Firefox) 4. A {{cssxref("contain")}} value of `layout`, `paint`, `strict` or `content` (e.g. `contain: paint;`) 5. A {{cssxref("container-type")}} value other than `normal` 6. A {{cssxref("backdrop-filter")}} other than `none` (e.g. `backdrop-filter: blur(10px);`) > **Note:** The containing block in which the root element ({{HTMLElement("html")}}) resides is a rectangle called the **initial containing block**. It has the dimensions of the viewport (for continuous media) or the page area (for paged media). > **Note:** There are browser inconsistencies with `perspective` and `filter` contributing to containing block formation. ## Calculating percentage values from the containing block As noted above, when certain properties are given a percentage value, the computed value depends on the element's containing block. The properties that work this way are **box model properties** and **offset properties**: 1. The {{cssxref("height")}}, {{cssxref("top")}}, and {{cssxref("bottom")}} properties compute percentage values from the `height` of the containing block. 2. The {{cssxref("width")}}, {{cssxref("left")}}, {{cssxref("right")}}, {{cssxref("padding")}}, and {{cssxref("margin")}} properties compute percentage values from the `width` of the containing block. > **Note:** A **block container** (such as an inline-block, block, or list-item element) either contains only inline-level boxes participating in an inline formatting context, or only block-level boxes participating in a block formatting context. An element is a block container only if it contains block-level or inline-level boxes. ## Some examples The HTML code for all our examples is: ```html <body> <section> <p>This is a paragraph!</p> </section> </body> ``` Only the CSS is altered in each instance below. ### Example 1 In this example, the paragraph is statically positioned, so its containing block is {{HTMLElement("section")}} because it's the nearest ancestor that is a block container (because of `display: block`). ```html hidden <body> <section> <p>This is a paragraph!</p> </section> </body> ``` ```css body { background: beige; } section { display: block; width: 400px; height: 160px; background: lightgray; } p { width: 50%; /* == 400px * .5 = 200px */ height: 25%; /* == 160px * .25 = 40px */ margin: 5%; /* == 400px * .05 = 20px */ padding: 5%; /* == 400px * .05 = 20px */ background: cyan; } ``` {{EmbedLiveSample('Example_1','100%','300')}} ### Example 2 In this example, the paragraph's containing block is the {{HTMLElement("body")}} element, because `<section>` is not a block container (because of `display: inline`) and doesn't establish a formatting context. ```html hidden <body> <section> <p>This is a paragraph!</p> </section> </body> ``` ```css body { background: beige; } section { display: inline; background: lightgray; } p { width: 50%; /* == half the body's width */ height: 200px; /* Note: a percentage would be 0 */ background: cyan; } ``` {{EmbedLiveSample('Example_2','100%','300')}} ### Example 3 In this example, the paragraph's containing block is `<section>` because the latter's `position` is `absolute`. The paragraph's percentage values are affected by the `padding` of its containing block, though if the containing block's {{cssxref("box-sizing")}} value were `border-box` this would not be the case. ```html hidden <body> <section> <p>This is a paragraph!</p> </section> </body> ``` ```css body { background: beige; } section { position: absolute; left: 30px; top: 30px; width: 400px; height: 160px; padding: 30px 20px; background: lightgray; } p { position: absolute; width: 50%; /* == (400px + 20px + 20px) * .5 = 220px */ height: 25%; /* == (160px + 30px + 30px) * .25 = 55px */ margin: 5%; /* == (400px + 20px + 20px) * .05 = 22px */ padding: 5%; /* == (400px + 20px + 20px) * .05 = 22px */ background: cyan; } ``` {{EmbedLiveSample('Example_3','100%','300')}} ### Example 4 In this example, the paragraph's `position` is `fixed`, so its containing block is the initial containing block (on screens, the viewport). Thus, the paragraph's dimensions change based on the size of the browser window. ```html hidden <body> <section> <p>This is a paragraph!</p> </section> </body> ``` ```css body { background: beige; } section { width: 400px; height: 480px; margin: 30px; padding: 15px; background: lightgray; } p { position: fixed; width: 50%; /* == (50vw - (width of vertical scrollbar)) */ height: 50%; /* == (50vh - (height of horizontal scrollbar)) */ margin: 5%; /* == (5vw - (width of vertical scrollbar)) */ padding: 5%; /* == (5vw - (width of vertical scrollbar)) */ background: cyan; } ``` {{EmbedLiveSample('Example_4','100%','300')}} ### Example 5 In this example, the paragraph's `position` is `absolute`, so its containing block is `<section>`, which is the nearest ancestor with a {{cssxref("transform")}} property that isn't `none`. ```html hidden <body> <section> <p>This is a paragraph!</p> </section> </body> ``` ```css body { background: beige; } section { transform: rotate(0deg); width: 400px; height: 160px; background: lightgray; } p { position: absolute; left: 80px; top: 30px; width: 50%; /* == 200px */ height: 25%; /* == 40px */ margin: 5%; /* == 20px */ padding: 5%; /* == 20px */ background: cyan; } ``` {{EmbedLiveSample('Example_5','100%','300')}} ## See also - The {{cssxref("all")}} property resets all CSS declarations to a given known state - CSS key concepts: - [CSS syntax](/en-US/docs/Web/CSS/Syntax) - [At-rules](/en-US/docs/Web/CSS/At-rule) - [Comments](/en-US/docs/Web/CSS/Comments) - [Specificity](/en-US/docs/Web/CSS/Specificity) - [Inheritance](/en-US/docs/Web/CSS/Inheritance) - [Box model](/en-US/docs/Web/CSS/CSS_box_model/Introduction_to_the_CSS_box_model) - [Layout modes](/en-US/docs/Web/CSS/Layout_mode) - [Visual formatting models](/en-US/docs/Web/CSS/Visual_formatting_model) - [Margin collapsing](/en-US/docs/Web/CSS/CSS_box_model/Mastering_margin_collapsing) - Values - [Initial values](/en-US/docs/Web/CSS/initial_value) - [Computed values](/en-US/docs/Web/CSS/computed_value) - [Used values](/en-US/docs/Web/CSS/used_value) - [Actual values](/en-US/docs/Web/CSS/actual_value) - [Value definition syntax](/en-US/docs/Web/CSS/Value_definition_syntax) - [Shorthand properties](/en-US/docs/Web/CSS/Shorthand_properties) - [Replaced elements](/en-US/docs/Web/CSS/Replaced_element)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/font-palette/index.md
--- title: font-palette slug: Web/CSS/font-palette page-type: css-property browser-compat: css.properties.font-palette --- {{CSSRef}} The **`font-palette`** [CSS](/en-US/docs/Web/CSS) property allows specifying one of the many palettes contained in a font that a user agent should use for the font. Users can also override the values in a palette or create a new palette by using the [@font-palette-values](/en-US/docs/Web/CSS/@font-palette-values) at-rule. ## Syntax ```css /* Using a font-defined palette */ font-palette: normal; /* Using a user-defined palette */ font-palette: --one; ``` ### Values - `normal` - : Specifies the default color palette or the default glyph colorization (set by the font maker) to be used for the font. With this setting, the palette in the font at index 0 is rendered. - `light` - : Specifies the first palette in the font that matches 'light' to be used for the font. Some fonts contain metadata that identify a palette as applicable for a light (close to white) background. If a font does not have this metadata, the `light` value behaves as `normal`. - `dark` - : Specifies the first palette in the font that matches 'dark' to be used for the font. Some fonts contain metadata that identify a palette as applicable for a dark (close to black) background. If a font does not have this metadata, the value behaves as `normal`. - `<palette-identifier>` - : Allows you to specify your own values for the font palette by using the [@font-palette-values](/en-US/docs/Web/CSS/@font-palette-values) at-rule. This value is specified using the [&lt;dashed-ident&gt;](/en-US/docs/Web/CSS/dashed-ident) format. ## Formal definition {{CSSInfo}} ## Formal syntax {{CSSSyntax}} ## Examples ### Specifying a dark palette This example allows you to use the first palette marked as _dark_ (works best on a near black background) by the font-maker. ```css @media (prefers-color-scheme: dark) { .banner { font-palette: dark; } } ``` ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{cssxref("@font-palette-values", "@font-palette-values")}} - {{cssxref("@font-palette-values/base-palette", "base-palette")}} descriptor - {{cssxref("@font-palette-values/font-family", "font-family")}} descriptor - {{cssxref("@font-palette-values/override-colors", "override-colors")}} descriptor
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/scroll-margin-left/index.md
--- title: scroll-margin-left slug: Web/CSS/scroll-margin-left page-type: css-property browser-compat: css.properties.scroll-margin-left --- {{CSSRef}} The `scroll-margin-left` property defines the left margin of the scroll snap area that is used for snapping this box to the snapport. The scroll snap area is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the scroll container's coordinate space), then adding the specified outsets. {{EmbedInteractiveExample("pages/css/scroll-margin-left.html")}} ## Syntax ```css /* <length> values */ scroll-margin-left: 10px; scroll-margin-left: 1em; /* Global values */ scroll-margin-left: inherit; scroll-margin-left: initial; scroll-margin-left: revert; scroll-margin-left: revert-layer; scroll-margin-left: unset; ``` ### Values - {{CSSXref("&lt;length&gt;")}} - : An outset from the left edge of the scroll container. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS scroll snap](/en-US/docs/Web/CSS/CSS_scroll_snap) - [Well-controlled scrolling with CSS scroll snap](https://web.dev/articles/css-scroll-snap)
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/animation-timing-function/index.md
--- title: animation-timing-function slug: Web/CSS/animation-timing-function page-type: css-property browser-compat: css.properties.animation-timing-function --- {{CSSRef}} The **`animation-timing-function`** [CSS](/en-US/docs/Web/CSS) property sets how an animation progresses through the duration of each cycle. {{EmbedInteractiveExample("pages/css/animation-timing-function.html")}} It is often convenient to use the shorthand property {{cssxref("animation")}} to set all animation properties at once. ## Syntax ```css /* Keyword values */ animation-timing-function: ease; animation-timing-function: ease-in; animation-timing-function: ease-out; animation-timing-function: ease-in-out; animation-timing-function: linear; animation-timing-function: step-start; animation-timing-function: step-end; /* Function values */ animation-timing-function: cubic-bezier(0.1, 0.7, 1, 0.1); animation-timing-function: steps(4, end); /* Steps Function keywords */ animation-timing-function: steps(4, jump-start); animation-timing-function: steps(10, jump-end); animation-timing-function: steps(20, jump-none); animation-timing-function: steps(5, jump-both); animation-timing-function: steps(6, start); animation-timing-function: steps(8, end); /* Multiple animations */ animation-timing-function: ease, step-start, cubic-bezier(0.1, 0.7, 1, 0.1); /* Global values */ animation-timing-function: inherit; animation-timing-function: initial; animation-timing-function: revert; animation-timing-function: revert-layer; animation-timing-function: unset; ``` ### Values - {{cssxref("&lt;easing-function&gt;")}} - : The easing function that corresponds to a given animation, as determined by {{cssxref("animation-name")}}. The non-step keyword values (ease, linear, ease-in-out, etc.) each represent cubic Bézier curve with fixed four point values, with the cubic-bezier() function value allowing for a non-predefined value. The step easing functions divides the input time into a specified number of intervals that are equal in length. It is defined by a number of steps and a step position. - `ease` - : Equal to `cubic-bezier(0.25, 0.1, 0.25, 1.0)`, the default value, increases in velocity towards the middle of the animation, slowing back down at the end. - `linear` - : Equal to `cubic-bezier(0.0, 0.0, 1.0, 1.0)`, animates at an even speed. - `ease-in` - : Equal to `cubic-bezier(0.42, 0, 1.0, 1.0)`, starts off slowly, with the speed of the transition of the animating property increasing until complete. - `ease-out` - : Equal to `cubic-bezier(0, 0, 0.58, 1.0)`, starts quickly, slowing down the animation continues. - `ease-in-out` - : Equal to `cubic-bezier(0.42, 0, 0.58, 1.0)`, with the animating properties slowly transitioning, speeding up, and then slowing down again. - `cubic-bezier(p1, p2, p3, p4)` - : An author defined cubic-bezier curve, where the p1 and p3 values must be in the range of 0 to 1. - `steps(n, <jumpterm>)` - : Displays an animation iteration along _n_ stops along the transition, displaying each stop for equal lengths of time. For example, if _n_ is 5, there are 5 steps. Whether the animation holds temporarily at 0%, 20%, 40%, 60% and 80%, on the 20%, 40%, 60%, 80% and 100%, or makes 5 stops between the 0% and 100% along the animation, or makes 5 stops including the 0% and 100% marks (on the 0%, 25%, 50%, 75%, and 100%) depends on which of the following jump terms is used: - `jump-start` - : Denotes a left-continuous function, so that the first jump happens when the animation begins. - `jump-end` - : Denotes a right-continuous function, so that the last jump happens when the animation ends. This is the default. - `jump-none` - : There is no jump on either end, effectively removing a step during the interpolation iteration. Instead, it holds at both the 0% mark and the 100% mark, each for 1/n of the duration. - `jump-both` - : Includes pauses at both the 0% and 100% marks, effectively adding a step during the animation iteration. - `start` - : Same as `jump-start`. - `end` - : Same as `jump-end`. - `step-start` - : Equal to `steps(1, jump-start)` - `step-end` - : Equal to `steps(1, jump-end)` > **Note:** When you specify multiple comma-separated values on an `animation-*` property, they are applied to the animations in the order in which the {{cssxref("animation-name")}}s appear. For situations where the number of animations and `animation-*` property values do not match, see [Setting multiple animation property values](/en-US/docs/Web/CSS/CSS_animations/Using_CSS_animations#setting_multiple_animation_property_values). > **Note:** `animation-timing-function` has the same effect when creating [CSS scroll-driven animations](/en-US/docs/Web/CSS/CSS_scroll-driven_animations) as it does for regular time-based animations. ## Description Easing functions may be specified on individual keyframes in a [@keyframes](/en-US/docs/Web/CSS/@keyframes) rule. If no **`animation-timing-function`** is specified on a keyframe, the corresponding value of **`animation-timing-function`** from the element to which the animation is applied is used for that keyframe. Within a keyframe, `animation-timing-function` is an at-rule-specific descriptor, not the property of the same name. The timing is not being animated. Rather, a keyframe's easing function is applied on a property-by-property basis from the keyframe on which it is specified until the next keyframe specifying that property, or until the end of the animation if there is no subsequent keyframe specifying that property. As a result, an **`animation-timing-function`** specified on the **`100%`** or **`to`** keyframe will never be used. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Cubic-Bezier examples ```html hidden <div class="parent"> <div class="ease">ease</div> <div class="easein">ease-in</div> <div class="easeout">ease-out</div> <div class="easeinout">ease-in-out</div> <div class="linear">linear</div> <div class="cb">cubic-bezier(0.2,-2,0.8,2)</div> </div> ``` ```css hidden .parent > div[class] { animation-name: changeme; animation-duration: 10s; animation-iteration-count: infinite; margin-bottom: 4px; } @keyframes changeme { 0% { min-width: 12em; width: 12em; background-color: black; border: 1px solid red; color: white; } 100% { width: 90vw; min-width: 24em; background-color: magenta; color: yellow; border: 1px solid orange; } } ``` ```css .ease { animation-timing-function: ease; } .easein { animation-timing-function: ease-in; } .easeout { animation-timing-function: ease-out; } .easeinout { animation-timing-function: ease-in-out; } .linear { animation-timing-function: linear; } .cb { animation-timing-function: cubic-bezier(0.2, -2, 0.8, 2); } ``` {{EmbedLiveSample("Cubic-Bezier_examples", 600, 200)}} ### Step examples ```html hidden <div class="parent"> <div class="jump-start">jump-start</div> <div class="jump-end">jump-end</div> <div class="jump-both">jump-both</div> <div class="jump-none">jump-none</div> <div class="start">start</div> <div class="end">end</div> <div class="step-start">step-start</div> <div class="step-end">step-end</div> </div> ``` ```css hidden .parent > div[class] { animation-name: changeme; animation-duration: 10s; animation-iteration-count: infinite; margin-bottom: 4px; } @keyframes changeme { 0% { min-width: 12em; width: 12em; background-color: black; border: 1px solid red; color: white; } 100% { width: 90vw; min-width: 24em; background-color: magenta; color: yellow; border: 1px solid orange; } } ``` ```css .jump-start { animation-timing-function: steps(5, jump-start); } .jump-end { animation-timing-function: steps(5, jump-end); } .jump-none { animation-timing-function: steps(5, jump-none); } .jump-both { animation-timing-function: steps(5, jump-both); } .start { animation-timing-function: steps(5, start); } .end { animation-timing-function: steps(5, end); } .step-start { animation-timing-function: step-start; } .step-end { animation-timing-function: step-end; } ``` {{EmbedLiveSample("Step_examples", 600, 200)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Using CSS animations](/en-US/docs/Web/CSS/CSS_animations/Using_CSS_animations) - {{cssxref('easing-function')}} - JavaScript {{domxref("AnimationEvent")}} API - [cubic-bezier.com](https://cubic-bezier.com) - Other related animation properties: {{cssxref("animation")}}, {{cssxref("animation-composition")}}, {{cssxref("animation-delay")}}, {{cssxref("animation-direction")}}, {{cssxref("animation-duration")}}, {{cssxref("animation-fill-mode")}}, {{cssxref("animation-iteration-count")}}, {{cssxref("animation-name")}}, {{cssxref("animation-play-state")}}, {{cssxref("animation-timeline")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/column-rule/index.md
--- title: column-rule slug: Web/CSS/column-rule page-type: css-shorthand-property browser-compat: css.properties.column-rule --- {{CSSRef}} The **`column-rule`** [shorthand](/en-US/docs/Web/CSS/Shorthand_properties) [CSS](/en-US/docs/Web/CSS) property sets the width, style, and color of the line drawn between columns in a multi-column layout. {{EmbedInteractiveExample("pages/css/column-rule.html")}} ## Constituent properties This property is a shorthand for the following CSS properties: - {{Cssxref("column-rule-color")}} - {{Cssxref("column-rule-style")}} - {{Cssxref("column-rule-width")}} ## Syntax ```css column-rule: dotted; column-rule: solid 8px; column-rule: solid blue; column-rule: thick inset blue; /* Global values */ column-rule: inherit; column-rule: initial; column-rule: revert; column-rule: revert-layer; column-rule: unset; ``` ### Values The `column-rule` property is specified as one, two, or three of the values listed below, in any order. - `<'column-rule-width'>` - : Is a {{cssxref("&lt;length&gt;")}} or one of the three keywords, `thin`, `medium`, or `thick`. See {{cssxref("border-width")}} for details. - `<'column-rule-style'>` - : See {{cssxref("border-style")}} for possible values and details. - `<'column-rule-color'>` - : Is a {{cssxref("&lt;color&gt;")}} value. ## Formal definition {{cssinfo}} ## Formal syntax {{csssyntax}} ## Examples ### Example 1 ```css /* Same as "medium dotted currentcolor" */ p.foo { column-rule: dotted; } /* Same as "medium solid blue" */ p.bar { column-rule: solid blue; } /* Same as "8px solid currentcolor" */ p.baz { column-rule: solid 8px; } p.abc { column-rule: thick inset blue; } ``` ### Example 2 #### HTML ```html <p class="content-box"> This is a bunch of text split into three columns. Take note of how the `column-rule` property is used to adjust the style, width, and color of the rule that appears between the columns. </p> ``` #### CSS ```css .content-box { padding: 0.3em; background: #ff7; column-count: 3; column-rule: inset 2px #33f; } ``` #### Result {{EmbedLiveSample('Example_2')}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [Multiple-column Layout](/en-US/docs/Learn/CSS/CSS_layout/Multiple-column_Layout) - {{CSSXref("column-rule-style")}} - {{CSSXref("column-rule-width")}} - {{CSSXref("column-rule-color")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/border-block-start-color/index.md
--- title: border-block-start-color slug: Web/CSS/border-block-start-color page-type: css-property browser-compat: css.properties.border-block-start-color --- {{CSSRef}} The **`border-block-start-color`** [CSS](/en-US/docs/Web/CSS) property defines the color of the logical block-start border of an element, which maps to a physical border color depending on the element's writing mode, directionality, and text orientation. It corresponds to the {{cssxref("border-top-color")}}, {{cssxref("border-right-color")}}, {{cssxref("border-bottom-color")}}, or {{cssxref("border-left-color")}} property depending on the values defined for {{cssxref("writing-mode")}}, {{cssxref("direction")}}, and {{cssxref("text-orientation")}}. {{EmbedInteractiveExample("pages/css/border-block-start-color.html")}} ## Syntax ```css border-block-start-color: blue; border-block-start-color: #4c5d21; /* Global values */ border-block-start-color: inherit; border-block-start-color: initial; border-block-start-color: revert; border-block-start-color: revert-layer; border-block-start-color: unset; ``` Related properties are {{cssxref("border-block-end-color")}}, {{cssxref("border-inline-start-color")}}, and {{cssxref("border-inline-end-color")}}, which define the other border colors of the element. ### Values - {{CSSXref("&lt;color&gt;")}} - : The color of the border. ## Formal definition {{CSSInfo}} ## Formal syntax {{csssyntax}} ## Examples ### Border color with vertical text #### HTML ```html <div> <p class="exampleText">Example text</p> </div> ``` #### CSS ```css div { background-color: yellow; width: 120px; height: 120px; } .exampleText { writing-mode: vertical-lr; border: 10px solid blue; border-block-start-color: red; } ``` #### Results {{EmbedLiveSample("Border_color_with_vertical_text", 140, 140)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - [CSS Logical Properties and Values](/en-US/docs/Web/CSS/CSS_logical_properties_and_values) - This property maps to one of the physical border properties: {{cssxref("border-top-color")}}, {{cssxref("border-right-color")}}, {{cssxref("border-bottom-color")}}, or {{cssxref("border-left-color")}}. - {{cssxref("writing-mode")}}, {{cssxref("direction")}}, {{cssxref("text-orientation")}}
0
data/mdn-content/files/en-us/web/css
data/mdn-content/files/en-us/web/css/color-interpolation-method/index.md
--- title: <color-interpolation-method> slug: Web/CSS/color-interpolation-method page-type: css-type browser-compat: - css.types.color.color-mix - css.types.image.gradient.conic-gradient.interpolation_color_space - css.types.image.gradient.linear-gradient.interpolation_color_space - css.types.image.gradient.radial-gradient.interpolation_color_space - css.types.image.gradient.repeating-conic-gradient.interpolation_color_space - css.types.image.gradient.repeating-linear-gradient.interpolation_color_space - css.types.image.gradient.repeating-radial-gradient.interpolation_color_space spec-urls: https://drafts.csswg.org/css-color/#interpolation-space --- {{CSSRef}} The **`<color-interpolation-method>`** [CSS](/en-US/docs/Web/CSS) [data type](/en-US/docs/Web/CSS/CSS_Types) represents the color space used for interpolation between {{CSSXref("&lt;color&gt;")}} values. It can be used to override the default interpolation color space for color-related functional notations such as {{CSSXref("color_value/color-mix", "color-mix()")}} and {{CSSXref("gradient/linear-gradient", "linear-gradient()")}}. When interpolating `<color>` values, the interpolation color space defaults to Oklab. ## Syntax The `<color-interpolation-method>` specifies whether interpolation should use a rectangular color space or a polar color space with an optional hue interpolation method: ```plain in <rectangular-color-space> // or in <polar-color-space>[ <hue-interpolation method>] ``` ### Values - `<rectangular-color-space>` - : One of the keywords `srgb`, `srgb-linear`, `lab`, `oklab`, `xyz`, `xyz-d50`, or `xyz-d65`. - `<polar-color-space>` - : One of the keywords `hsl`, `hwb`, `lch`, or `oklch`. - {{CSSXref("&lt;hue-interpolation-method&gt;")}} {{optional_inline}} - : The algorithm for hue interpolation. It defaults to `shorter hue`. ## Formal syntax {{CSSSyntax}} ## Examples ### Comparing interpolation color spaces using gradients The following example shows the effect of using different interpolation color spaces for {{CSSXref("gradient/linear-gradient", "linear-gradient()")}}. #### HTML ```html <div>sRGB:</div> <div class="gradient srgb"></div> <div>Oklab:</div> <div class="gradient oklab"></div> <div>Oklch (with <code>longer hue</code>):</div> <div class="gradient oklch-longer"></div> ``` #### CSS ```css hidden /* Fallback styles */ .srgb { background-image: linear-gradient( to right, rgb(0% 0% 100%), rgb(20% 0% 80%), rgb(40% 0% 60%), rgb(60% 0% 40%), rgb(80% 0% 20%), rgb(100% 0% 0%) ); } .oklab { background-image: linear-gradient( to right, oklab(45.2% -0.032 -0.312), oklab(48.7% 0.019 -0.224), oklab(52.2% 0.07 -0.137), oklab(55.8% 0.122 -0.049), oklab(59.3% 0.173 0.038), oklab(62.8% 0.225 0.126) ); } .oklch-longer { background-image: linear-gradient( to right, oklch(45.2% 0.313 264), oklch(46.8% 0.308 243), oklch(48.4% 0.303 221), oklch(50% 0.298 200), oklch(51.6% 0.293 179), oklch(53.2% 0.288 157), oklch(54.8% 0.283 136), oklch(56.4% 0.278 115), oklch(58% 0.273 93), oklch(59.6% 0.268 72), oklch(61.2% 0.263 51), oklch(62.8% 0.258 29) ); } ``` ```css .gradient { height: 50px; width: 100%; } .srgb { background-image: linear-gradient(in srgb to right, blue, red); } .oklab { background-image: linear-gradient(in oklab to right, blue, red); } .oklch-longer { background-image: linear-gradient(in oklch longer hue to right, blue, red); } ``` #### Result {{EmbedLiveSample("comparing_interpolation_color_spaces_using_gradients", "100%", 250)}} ## Specifications {{Specifications}} ## Browser compatibility {{Compat}} ## See also - {{CSSXref("&lt;color&gt;")}}, {{CSSXref("&lt;gradient&gt;")}} - {{CSSXref("&lt;hue-interpolation-method&gt;")}}
0