GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

CSSPositionTryRule

CSSOM

CSSOM

The **`CSSPositionTryRule`** interface describes an object representing a @position-try [at-rule](/docs/Web/CSS/Guides/Syntax/At-rules).

## Instance properties

_Inherits properties from its ancestor CSSRule._

- CSSPositionTryRule.name
- : Represents the name of the position try option specified by the `@position-try` at-rule's dashed-ident.
- CSSPositionTryRule.style
- : A CSSPositionTryDescriptors object that represents the declarations set in the body of the `@position-try` at-rule.

## Instance methods

_No specific methods; inherits methods from its ancestor CSSRule._

## Examples

The CSS includes a `@position-try` at-rule with a name of `--custom-left` and three descriptors.

```css
@position-try --custom-left {
position-area: left;
width: 20%;
max-width: 200px;
margin-right: 10px;
}
```

```js
const myRules = document.styleSheets[0].cssRules;
const tryOption = myRules[0]; // a CSSPositionTryRule
console.log(tryOption); // "[object CSSPositionTryRule]"
console.log(tryOption.name); // "--custom-left"
console.log(tryOption.style); // "[object CSSPositionTryDescriptors]"
console.log(tryOption.style.maxWidth); // "200px"
```

## Specifications

## Browser compatibility

## See also

- CSSPositionTryDescriptors
- @position-try
- position-try-fallbacks
- [CSS anchor positioning](/docs/Web/CSS/Guides/Anchor_positioning) module
- [Using CSS anchor positioning](/docs/Web/CSS/Guides/Anchor_positioning/Using)
- [Handling overflow: try options and conditional hiding](/docs/Web/CSS/Guides/Anchor_positioning/Try_options_hiding)

source: MDN Web Docs mirror · page

Cite this

"CSSPositionTryRule". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/CSSPositionTryRule

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·