CSS current keywords are special values that let you refer to the current or inherited value of a property. They help you:
currentColor: Uses the element’s current color (text color) for other color-related properties like border, outline, box-shadow, and SVG strokes.inherit: Forces a property to take the computed value from its parent element, even if that property does not usually inherit by default.currentColor:
color value.color automatically updates all places that use currentColor.inherit:
border).This example shows how currentColor reuses the text color for the border and how inherit makes a child element use its parent’s color.
/* Use currentColor so the border matches the text color */
.box {
color: #007bff;
border: 2px solid currentColor;
padding: 15px;
margin-bottom: 20px;
}
/* Force the child to inherit the parent text color */
.child {
color: inherit;
background-color: #f0f0f0;
padding: 15px;
}
Imagine this HTML structure:
<div class="box">...<div class="child">...</div></div>
color: #007bff;.border: 2px solid currentColor;.color: inherit;, so it gets the same blue text color from its parent.color and have all related styles update automatically.currentColor so they follow the surrounding text color.inherit.currentColor wherever possible for borders, outlines, and shadows to keep colors consistent.inherit when you want a child to follow a parent’s style instead of setting the same value again.currentColor with CSS variables for powerful theming systems.inherit copies from the parent, while initial resets to the browser’s default..button class where the text, border, and box-shadow all use currentColor. Change color and observe the effect.color: darkgreen; and add child elements that use color: inherit;. Confirm that all children turn dark green..card component where only the root sets color. Use inherit on headings and paragraphs inside it.color and see how components using currentColor adapt automatically.