-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
CSS Basics
CSS Styling Properties
CSS Box Model
CSS Margin
CSS Padding
CSS Borders
CSS Outline
CSS Height/Width
CSS Max-width
CSS Display
CSS Position
CSS Z-index
CSS Overflow
CSS Float
CSS Inline-block
CSS Align
CSS Box Sizing
CSS Text
CSS Fonts
CSS Icons
CSS Text Effects
CSS Web Fonts
CSS Colors
CSS Backgrounds
CSS Color Keywords
CSS Gradients
CSS Shadows
CSS Links
CSS Lists
CSS Tables
CSS Advanced Selectors & Features
CSS Combinators
CSS Pseudo-classes
CSS Pseudo-elements
CSS Attribute Selectors
CSS Specificity
CSS !important
CSS Units
CSS Variables
CSS @property
CSS Math Functions
CSS Media and Image Styling
CSS Image Styling
CSS Image Centering
CSS Image Filters
CSS Image Shapes
CSS object-fit
CSS object-position
CSS Masking
CSS Layout Techniques
CSS Website Layout
CSS Navigation Bar
CSS Dropdowns
CSS Image Gallery
CSS Counters
CSS Pagination
CSS Multiple Columns
CSS User Interface
CSS Flexbox
CSS Grid
CSS Responsive Design (RWD)
@property
?CSS @property
is an at-rule that allows developers to define typed custom properties (variables) in CSS with additional control like defining the expected data type, syntax, and inheritance behavior.
It enhances the capabilities of regular CSS variables (--custom-property
) by making them more animation-friendly and type-safe.
🔧 Note:
@property
is supported in modern browsers like Chrome and Edge. Firefox support is still experimental.
@property --property-name {
syntax: '<data-type>';
inherits: true | false;
initial-value: defaultValue;
}
Property | Description |
---|---|
syntax |
Defines the type of value (<color> , <length> , <number> , etc.) |
inherits |
Boolean. Whether the variable should inherit from its parent |
initial-value |
The default value if none is defined |
@property --main-color {
syntax: '<color>';
inherits: false;
initial-value: #3498db;
}
:root {
--main-color: red;
}
h1 {
color: var(--main-color);
}
@property --progress {
syntax: '<number>';
inherits: false;
initial-value: 0;
}
.box {
--progress: 0;
animation: fill 3s forwards;
}
@keyframes fill {
to {
--progress: 100;
}
}
Now this value can be used in width
, transform
, etc., dynamically.
@property
?✅ Enables animation of custom properties
✅ Adds type-checking to variables
✅ Allows default/fallback values
✅ Controls inheritance behavior
Syntax | Meaning |
---|---|
<color> |
Any valid CSS color |
<length> |
px, em, rem, etc. |
<number> |
Any number (no unit) |
<percentage> |
% values |
<angle> |
deg, rad, etc. |
<transform-function> |
rotate(), scale(), etc. |
Q1. Define a typed color custom property --accent-color
with default blue
.
Q2. Create a <number>
property --scale-factor
for animations.
Q3. Animate --width-percent
from 0
to 100
.
Q4. Use --angle
in a rotate()
transform with animation.
Q5. Make a --padding-size
custom property using <length>
.
Q6. Create an @property
and use it in a box-shadow color.
Q7. Add a fallback color using initial-value
in @property
.
Q8. Create an inherited variable --font-scale
and apply it.
Q9. Use --lightness
property and animate HSL values.
Q10. Declare a custom property with <percentage>
syntax for responsive layout.
CSS Basics
CSS Styling Properties
CSS Box Model
CSS Margin
CSS Padding
CSS Borders
CSS Outline
CSS Height/Width
CSS Max-width
CSS Display
CSS Position
CSS Z-index
CSS Overflow
CSS Float
CSS Inline-block
CSS Align
CSS Box Sizing
CSS Text
CSS Fonts
CSS Icons
CSS Text Effects
CSS Web Fonts
CSS Colors
CSS Backgrounds
CSS Color Keywords
CSS Gradients
CSS Shadows
CSS Links
CSS Lists
CSS Tables
CSS Advanced Selectors & Features
CSS Combinators
CSS Pseudo-classes
CSS Pseudo-elements
CSS Attribute Selectors
CSS Specificity
CSS !important
CSS Units
CSS Variables
CSS @property
CSS Math Functions
CSS Media and Image Styling
CSS Image Styling
CSS Image Centering
CSS Image Filters
CSS Image Shapes
CSS object-fit
CSS object-position
CSS Masking
CSS Layout Techniques
CSS Website Layout
CSS Navigation Bar
CSS Dropdowns
CSS Image Gallery
CSS Counters
CSS Pagination
CSS Multiple Columns
CSS User Interface
CSS Flexbox
CSS Grid
CSS Responsive Design (RWD)