Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion files/en-us/web/css/@layer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,32 @@ browser-compat: css.at-rules.layer

The **`@layer`** [CSS](/en-US/docs/Web/CSS) [at-rule](/en-US/docs/Web/CSS/CSS_syntax/At-rule) is used to declare a cascade layer and can also be used to define the order of precedence in case of multiple cascade layers.

{{EmbedInteractiveExample("pages/tabbed/at-rule-layer.html", "tabbed-standard")}}
{{InteractiveExample("CSS Demo: @layer", "tabbed-standard")}}

```css interactive-example
@layer module, state;

@layer state {
.alert {
background-color: brown;
}
p {
border: medium solid limegreen;
}
}

@layer module {
.alert {
border: medium solid violet;
background-color: yellow;
color: white;
}
}
```

```html interactive-example
<p class="alert">Beware of the zombies</p>
```

## Syntax

Expand Down
29 changes: 28 additions & 1 deletion files/en-us/web/css/@media/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,34 @@ The **`@media`** [CSS](/en-US/docs/Web/CSS) [at-rule](/en-US/docs/Web/CSS/CSS_sy
> [!NOTE]
> In JavaScript, the rules created using `@media` can be accessed with the {{domxref("CSSMediaRule")}} CSS object model interface.

{{EmbedInteractiveExample("pages/tabbed/at-rule-media.html", "tabbed-standard")}}
{{InteractiveExample("CSS Demo: @media", "tabbed-standard")}}

```css interactive-example
abbr {
color: chocolate;
}

@media (hover: hover) {
abbr:hover {
color: limegreen;
transition-duration: 1s;
}
}

@media not all and (hover: hover) {
abbr::after {
content: " (" attr(title) ")";
}
}
```

```html interactive-example
<p>
<abbr title="National Aeronautics and Space Administration">NASA</abbr> is a
U.S. government agency that is responsible for science and technology related
to air and space.
</p>
```

## Syntax

Expand Down
30 changes: 29 additions & 1 deletion files/en-us/web/css/@namespace/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,35 @@ browser-compat: css.at-rules.namespace

**`@namespace`** is an [at-rule](/en-US/docs/Web/CSS/CSS_syntax/At-rule) that defines XML [namespaces](/en-US/docs/Glossary/Namespace) to be used in a [CSS](/en-US/docs/Glossary/CSS) [style sheet](/en-US/docs/Web/API/StyleSheet).

{{EmbedInteractiveExample("pages/tabbed/at-rule-namespace.html", "tabbed-shorter")}}
{{InteractiveExample("CSS Demo: @namespace", "tabbed-shorter")}}

```css interactive-example
@namespace svg url("http://www.w3.org/2000/svg");

a {
color: orangered;
text-decoration: underline dashed;
font-weight: bold;
}

svg|a {
fill: blueviolet;
text-decoration: underline solid;
text-transform: uppercase;
}
```

```html interactive-example
<p>
<a href="#">This is an ordinary HTML link</a>
</p>

<svg width="250px" viewBox="0 0 250 20" xmlns="http://www.w3.org/2000/svg">
<a href="#">
<text x="0" y="15">This is a link created in SVG</text>
</a>
</svg>
```

## Syntax

Expand Down
30 changes: 29 additions & 1 deletion files/en-us/web/css/@supports/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,35 @@ The **`@supports`** [CSS](/en-US/docs/Web/CSS) [at-rule](/en-US/docs/Web/CSS/CSS
Using this at-rule is commonly called a _feature query_.
The rule must be placed at the top level of your code or nested inside any other conditional group at-rule.

{{EmbedInteractiveExample("pages/tabbed/at-rule-supports.html", "tabbed-standard")}}
{{InteractiveExample("CSS Demo: @supports", "tabbed-standard")}}

```css interactive-example
.flex-container > * {
padding: 0.3em;
list-style-type: none;
text-shadow: 0 0 2px red;
float: left;
}

@supports (display: flex) {
.flex-container > * {
text-shadow: 0 0 2px blue;
float: none;
}

.flex-container {
display: flex;
}
}
```

```html interactive-example
<ul class="flex-container">
<li><a href="#">Index</a></li>
<li><a href="#">About me</a></li>
<li><a href="#">Contact</a></li>
</ul>
```

In JavaScript, `@supports` can be accessed via the CSS object model interface {{DOMxRef("CSSSupportsRule")}}.

Expand Down
24 changes: 23 additions & 1 deletion files/en-us/web/css/_colon_active/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,29 @@ browser-compat: css.selectors.active

The **`:active`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) represents an element (such as a button) that is being activated by the user. When using a mouse, "activation" typically starts when the user presses down the primary mouse button.

{{EmbedInteractiveExample("pages/tabbed/pseudo-class-active.html", "tabbed-shorter")}}
{{InteractiveExample("CSS Demo: :active", "tabbed-shorter")}}

```css interactive-example
.joinBtn {
width: 10em;
height: 5ex;
background-image: linear-gradient(135deg, #f34079 40%, #fc894d);
border: none;
border-radius: 5px;
font-weight: bold;
color: white;
cursor: pointer;
}

.joinBtn:active {
box-shadow: 2px 2px 5px #fc894d;
}
```

```html interactive-example
<p>Would you like to subscribe to our channel?</p>
<button class="joinBtn">Subscribe</button>
```

The `:active` pseudo-class is commonly used on {{HTMLElement("a")}} and {{HTMLElement("button")}} elements. Other common targets of this pseudo-class include elements that are _contained in_ an activated element, and form elements that are being activated through their associated {{HTMLElement("label")}}.

Expand Down
34 changes: 33 additions & 1 deletion files/en-us/web/css/_colon_any-link/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,39 @@ browser-compat: css.selectors.any-link

The **`:any-link`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) selector represents an element that acts as the source anchor of a hyperlink, independent of whether it has been visited. In other words, it matches every {{HTMLElement("a")}} or {{HTMLElement("area")}} element that has an `href` attribute. Thus, it matches all elements that match {{cssxref(":link")}} or {{cssxref(":visited")}}.

{{EmbedInteractiveExample("pages/tabbed/pseudo-class-any-link.html", "tabbed-shorter")}}
{{InteractiveExample("CSS Demo: :any-link", "tabbed-shorter")}}

```css interactive-example
p {
font-weight: bold;
}

a:any-link {
color: forestgreen;
text-decoration-color: hotpink;
}
```

```html interactive-example
<p>Pages that you might have visited:</p>
<ul>
<li>
<a href="https://developer.mozilla.org">MDN Web Docs</a>
</li>
<li>
<a href="https://www.youtube.com/YouTube">Google</a>
</li>
</ul>
<p>Pages unlikely to be in your history:</p>
<ul>
<li>
<a href="https://developer.mozilla.org/missing-3">Random MDN page</a>
</li>
<li>
<a href="https://example.com/missing-3">Random Example page</a>
</li>
</ul>
```

## Syntax

Expand Down
28 changes: 27 additions & 1 deletion files/en-us/web/css/_colon_autofill/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,33 @@ browser-compat: css.selectors.autofill

The **`:autofill`** CSS [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) matches when an {{HTMLElement("input")}} element has its value autofilled by the browser. The class stops matching if the user edits the field.

{{EmbedInteractiveExample("pages/tabbed/pseudo-class-autofill.html", "tabbed-shorter")}}
{{InteractiveExample("CSS Demo: :autofill", "tabbed-shorter")}}

```css interactive-example
label {
display: block;
margin-top: 1em;
}

input:is(:-webkit-autofill, :autofill) {
border: 3px solid darkorange;
}
```

```html interactive-example
<form>
<p>Click on the text box and choose any option suggested by your browser.</p>

<label for="name">Name</label>
<input id="name" name="name" type="text" autocomplete="name" />

<label for="email">Email Address</label>
<input id="email" name="email" type="email" autocomplete="email" />

<label for="country">Country</label>
<input id="country" name="country" type="text" autocomplete="country-name" />
</form>
```

> [!NOTE]
> The user agent style sheets of many browsers use `!important` in their `:-webkit-autofill` style declarations, making them non-overridable by webpages without resorting to JavaScript hacks. For example Chrome has the following in its internal stylesheet:
Expand Down
38 changes: 37 additions & 1 deletion files/en-us/web/css/_colon_checked/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,43 @@ browser-compat: css.selectors.checked

The **`:checked`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) selector represents any **radio** ([`<input type="radio">`](/en-US/docs/Web/HTML/Element/input/radio)), **checkbox** ([`<input type="checkbox">`](/en-US/docs/Web/HTML/Element/input/checkbox)), or **option** ({{HTMLElement("option")}} in a {{HTMLElement("select")}}) element that is checked or toggled to an `on` state.

{{EmbedInteractiveExample("pages/tabbed/pseudo-class-checked.html", "tabbed-shorter")}}
{{InteractiveExample("CSS Demo: :checked", "tabbed-shorter")}}

```css interactive-example
label,
input[type="submit"] {
display: block;
margin-top: 1em;
}

input:checked {
border: none;
outline: 2px solid deeppink;
}
```

```html interactive-example
<form>
<p>How did you find out about us?</p>
<label
><input name="origin" type="radio" value="google" checked /> Google</label
>
<label><input name="origin" type="radio" value="facebook" /> Facebook</label>
<p>Please agree to our terms:</p>

<label
><input name="newsletter" type="checkbox" checked /> I want to subscribe to
a personalized newsletter.</label
>

<label
><input name="privacy" type="checkbox" /> I have read and I agree to the
Privacy Policy.</label
>

<input type="submit" value="Submit form" />
</form>
```

The user can engage this state by checking/selecting an element, or disengage it by unchecking/deselecting the element.

Expand Down
38 changes: 37 additions & 1 deletion files/en-us/web/css/_colon_default/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,43 @@ browser-compat: css.selectors.default

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")}}
{{InteractiveExample("CSS Demo: :default", "tabbed-shorter")}}

```css interactive-example
label,
input[type="submit"] {
display: block;
margin-top: 1em;
}

input:default {
border: none;
outline: 2px solid deeppink;
}
```

```html interactive-example
<form>
<p>How did you find out about us?</p>
<label
><input name="origin" type="radio" value="google" checked /> Google</label
>
<label><input name="origin" type="radio" value="facebook" /> Facebook</label>
<p>Please agree to our terms:</p>

<label
><input name="newsletter" type="checkbox" checked /> I want to subscribe to
a personalized newsletter.</label
>

<label
><input name="privacy" type="checkbox" /> I have read and I agree to the
Privacy Policy.</label
>

<input type="submit" value="Submit form" />
</form>
```

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:

Expand Down
34 changes: 33 additions & 1 deletion files/en-us/web/css/_colon_disabled/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,39 @@ browser-compat: css.selectors.disabled

The **`:disabled`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) represents any disabled element. An element is disabled if it can't be activated (selected, clicked on, typed into, etc.) or accept focus. The element also has an enabled state, in which it can be activated or accept focus.

{{EmbedInteractiveExample("pages/tabbed/pseudo-class-disabled.html", "tabbed-standard")}}
{{InteractiveExample("CSS Demo: :disabled", "tabbed-standard")}}

```css interactive-example
label {
display: block;
margin-top: 1em;
}

*:disabled {
background-color: dimgrey;
color: linen;
opacity: 1;
}
```

```html interactive-example
<form>
<label for="name">Name:</label>
<input id="name" name="name" type="text" />

<label for="emp">Employed:</label>
<select id="emp" name="emp" disabled>
<option>No</option>
<option>Yes</option>
</select>

<label for="empDate">Employment Date:</label>
<input id="empDate" name="empDate" type="date" disabled />

<label for="resume">Resume:</label>
<input id="resume" name="resume" type="file" />
</form>
```

## Syntax

Expand Down
Loading