CSSPositionTryDescriptors
        
        
          Limited availability
        
        
        
          
                
              
                
              
                
              
        
        
      
      This feature is not Baseline because it does not work in some of the most widely-used browsers.
The CSSPositionTryDescriptors interface defines properties that represent the list of CSS descriptors that can be set in the body of a @position-try at-rule.
Each descriptor in the body of the corresponding @position-try at-rule can be accessed using either its property name in bracket notation or the camel-case version of the property name "propertyName" in dot notation.
For example, you can access the CSS property "property-name" as style["property-name"] or style.propertyName, where style is a CSSPositionTryDescriptors instance.
A property with a single-word name like height can be accessed using either notation: style["height"] or style.height.
Note:
The CSSPositionTryRule interface represents a @position-try at-rule, and the CSSPositionTryRule.style property is an instance of this object.
Instance properties
Inherits properties from its ancestor CSSStyleDeclaration.
The following property names, in snake-case (accessed using bracket notation) and camel-case (accessed using dot notation), each represent the value of a descriptor in the corresponding @position-try at-rule:
- align-selfor- alignSelf
- 
A string representing the value of an align-selfdescriptor.
- block-sizeor- blockSize
- 
A string representing the value of a block-sizedescriptor.
- bottom
- 
A string representing the value of a bottomdescriptor.
- height
- 
A string representing the value of a heightdescriptor.
- inline-sizeor- inlineSize
- 
A string representing the value of an inline-sizedescriptor.
- inset
- 
A string representing the value of an insetdescriptor.
- position-areaor- positionArea
- 
A string representing the value of a position-areadescriptor.
- inset-blockor- insetBlock
- 
A string representing the value of an inset-blockdescriptor.
- inset-block-endor- insetBlockEnd
- 
A string representing the value of an inset-block-enddescriptor.
- inset-block-startor- insetBlockStart
- 
A string representing the value of an inset-block-startdescriptor.
- inset-inlineor- insetInline
- 
A string representing the value of an inset-inlinedescriptor.
- inset-inline-endor- insetInlineEnd
- 
A string representing the value of an inset-inline-enddescriptor.
- inset-inline-startor- insetInlineStart
- 
A string representing the value of an inset-inline-startdescriptor.
- justify-selfor- justifySelf
- 
A string representing the value of a justify-selfdescriptor.
- left
- 
A string representing the value of a leftdescriptor.
- margin
- 
A string representing the value of a margindescriptor.
- margin-blockor- marginBlock
- 
A string representing the value of a margin-blockdescriptor.
- margin-block-endor- marginBlockEnd
- 
A string representing the value of a margin-block-enddescriptor.
- margin-block-startor- marginBlockStart
- 
A string representing the value of a margin-block-startdescriptor.
- margin-bottomor- marginBottom
- 
A string representing the value of a margin-bottomdescriptor.
- margin-inlineor- marginInline
- 
A string representing the value of a margin-inlinedescriptor.
- margin-inline-endor- marginInlineEnd
- 
A string representing the value of a margin-inline-enddescriptor.
- margin-inline-startor- marginInlineStart
- 
A string representing the value of a margin-inline-startdescriptor.
- margin-leftor- marginLeft
- 
A string representing the value of a margin-leftdescriptor.
- margin-rightor- marginRight
- 
A string representing the value of a margin-rightdescriptor.
- margin-topor- marginTop
- 
A string representing the value of a margin-topdescriptor.
- max-block-sizeor- maxBlockSize
- 
A string representing the value of a max-block-sizedescriptor.
- max-heightor- maxHeight
- 
A string representing the value of a max-heightdescriptor.
- max-inline-sizeor- maxInlineSize
- 
A string representing the value of a max-inline-sizedescriptor.
- max-widthor- maxWidth
- 
A string representing the value of a max-widthdescriptor.
- min-block-sizeor- minBlockSize
- 
A string representing the value of a min-block-sizedescriptor.
- min-heightor- minHeight
- 
A string representing the value of a min-heightdescriptor.
- min-inline-sizeor- minInlineSize
- 
A string representing the value of a min-inline-sizedescriptor.
- min-widthor- minWidth
- 
A string representing the value of a min-widthdescriptor.
- place-selfor- placeSelf
- 
A string representing the value of a place-selfdescriptor.
- position-anchoror- positionAnchor
- 
A string representing the value of a position-anchordescriptor.
- right
- 
A string representing the value of a rightdescriptor.
- top
- 
A string representing the value of a topdescriptor.
- width
- 
A string representing the value of a widthdescriptor.
Instance methods
No specific methods; inherits methods from its ancestor CSSStyleDeclaration.
Examples
The CSS includes a @position-try at-rule with a name of --custom-right and three descriptors.
@position-try --custom-right {
  position-area: right;
  width: 100px;
  margin-left: 10px;
}
const myRules = document.styleSheets[0].cssRules;
const tryOption = myRules[0]; // a CSSPositionTryRule
console.log(tryOption.style); // "[object CSSPositionTryDescriptors]"
console.log(tryOption.style.margin); // "0 0 0 10px"
console.log(tryOption.style["position-area"]); // "right"
Specifications
| Specification | 
|---|
| CSS Anchor Positioning> # csspositiontrydescriptors> | 
Browser compatibility
Loading…