Explain the purpose and usage of the 'currentColor' value in CSS.

Instruction: Describe how 'currentColor' works and provide examples of its practical applications.

Context: This question probes the candidate's understanding of the 'currentColor' keyword, a versatile tool in CSS for styling elements based on the current color context.

Updated

Official answer available

Read the opening below, then unlock the full answer and practical guidance.

currentColor represents the element's own color value when used by other color-valued properties. It is useful for keeping borders, shadows or an SVG fill aligned with text. It is not a saved copy of an earlier color declaration.

<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS example</title> <style> .button { color: navy; background: white; border: 2px solid currentColor; padding: .5rem; } .button svg { width: 1em; height: 1em; fill: currentColor; } .button:hover { color: white; background: navy;...

Related Questions