|

CSS 37 ๐Ÿ’ป hover and inverted colors media features

These two media features help you create input-aware and accessibility-friendly interfaces โ€” one detects hover capability, the other detects inverted color schemes.


Overview of Features

FeatureDescriptionValues
hoverDetects if the primary pointing device can hovernone, hover
inverted-colorsDetects if the system uses inverted colorsnone, inverted

1. hover

The hover media feature applies styles when the primary pointing device can hover over elements.

@media (hover: hover) {
    button:hover {
        background-color: red;
    }
}

Values

ValueDescription
nonePrimary input cannot hover (e.g., touch screen)
hoverPrimary input can hover (e.g., mouse, trackpad)

Key Points:

  • hover checks the primary pointing device
  • any-hover checks any available pointing device
  • Use hover to ensure hover effects only apply when they make sense
  • On touch devices, :hover can be triggered accidentally โ€” use @media (hover: hover) to prevent this

hover vs any-hover

FeatureDescription
hoverPrimary pointing device’s hover capability
any-hoverAny pointing device’s hover capability

Example:

  • Tablet with Bluetooth mouse:
    • hover: none (primary is touch)
    • any-hover: hover (mouse can hover)

2. inverted-colors

The inverted-colors media feature applies styles when the system’s display uses an inverted color scheme โ€” where dark colors become bright and vice versa.

@media (inverted-colors: inverted) {
    body {
        background-color: black;
        color: white;
    }
}

Values

ValueDescription
noneColors are displayed normally
invertedDisplay uses inverted color scheme

Key Points:

  • Inverted colors are used for accessibility (poor visibility conditions)
  • Common on iOS (Accessibility > Display & Text Size > Classic Invert)
  • Images and media may be double-inverted โ€” use filter: invert(1) to counter
  • Helps make content readable when inverted colors are enabled

Handling Images in Inverted Mode

@media (inverted-colors: inverted) {
    /* Re-invert images so they look normal */
    img, video {
        filter: invert(1);
    }
}

Complete Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>hover and inverted-colors Media Features</title>
    <style>
        *, *::before, *::after {
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            padding: 20px;
            background: #f8f9fa;
            color: #333;
            max-width: 1200px;
            margin: 0 auto;
            line-height: 1.6;
            transition: background 0.3s, color 0.3s;
        }

        h1 {
            color: #007bff;
            border-bottom: 3px solid #007bff;
            padding-bottom: 10px;
        }

        h2 {
            color: #28a745;
            border-left: 4px solid #28a745;
            padding-left: 15px;
            margin-top: 30px;
        }

        h3 {
            color: #333;
            margin-top: 20px;
        }

        section {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            margin: 20px 0;
            transition: background 0.3s;
        }

        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            padding: 15px;
            border-radius: 8px;
            overflow-x: auto;
            font-family: 'Courier New', monospace;
            font-size: 0.9rem;
            line-height: 1.8;
            margin: 10px 0;
        }

        .reference-table {
            width: 100%;
            border-collapse: collapse;
            margin: 15px 0;
        }

        .reference-table th,
        .reference-table td {
            padding: 10px;
            border: 1px solid #ddd;
            text-align: left;
        }

        .reference-table th {
            background: #007bff;
            color: white;
        }

        .reference-table tr:nth-child(even) {
            background: #f8f9fa;
        }

        .note {
            font-size: 0.9rem;
            color: #6c757d;
            margin-top: 5px;
        }

        .highlight {
            background: #ffc107;
            color: #333;
            padding: 2px 6px;
            border-radius: 4px;
            font-weight: bold;
        }

        /* ====== BUTTON STYLES ====== */
        button {
            padding: 12px 24px;
            font-size: 16px;
            color: white;
            background-color: #007bff;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-weight: bold;
            transition: all 0.3s;
            margin: 5px;
        }

        /* Hover effect only for devices that can hover */
        @media (hover: hover) {
            button:hover {
                background-color: #dc3545;
                transform: translateY(-2px);
                box-shadow: 0 4px 15px rgba(220, 53, 69, 0.4);
            }
        }

        /* For touch devices โ€” use :active instead */
        @media (hover: none) {
            button:active {
                background-color: #dc3545;
                transform: scale(0.98);
            }
            button::after {
                content: " (tap me)";
                font-weight: normal;
                font-size: 0.8rem;
                opacity: 0.8;
            }
        }

        /* ====== CARD STYLES ====== */
        .card {
            background: white;
            border: 2px solid #ddd;
            border-radius: 12px;
            padding: 20px;
            margin: 15px 0;
            transition: all 0.3s;
            cursor: pointer;
        }

        @media (hover: hover) {
            .card:hover {
                border-color: #007bff;
                box-shadow: 0 4px 20px rgba(0, 123, 255, 0.15);
                transform: translateY(-3px);
            }
        }

        @media (hover: none) {
            .card:active {
                border-color: #007bff;
                background: #f0f7ff;
            }
        }

        /* ====== TOOLTIP STYLES ====== */
        .tooltip-container {
            position: relative;
            display: inline-block;
            margin: 10px;
        }

        .tooltip-text {
            visibility: hidden;
            opacity: 0;
            background: #333;
            color: white;
            padding: 8px 12px;
            border-radius: 6px;
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%);
            white-space: nowrap;
            font-size: 0.85rem;
            transition: all 0.3s;
            margin-bottom: 8px;
        }

        .tooltip-text::after {
            content: "";
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            border: 6px solid transparent;
            border-top-color: #333;
        }

        @media (hover: hover) {
            .tooltip-container:hover .tooltip-text {
                visibility: visible;
                opacity: 1;
            }
        }

        /* ====== INVERTED COLORS DEMO ====== */
        .invert-demo {
            padding: 20px;
            border-radius: 8px;
            background: #e9ecef;
            margin: 15px 0;
            border: 2px solid #ddd;
            transition: all 0.3s;
        }

        .invert-demo .box {
            padding: 15px;
            background: #007bff;
            color: white;
            border-radius: 8px;
            margin: 10px 0;
            text-align: center;
            font-weight: bold;
            transition: all 0.3s;
        }

        /* Inverted colors mode */
        @media (inverted-colors: inverted) {
            body {
                background: #000;
                color: #fff;
            }
            section {
                background: #1a1a1a;
                border: 1px solid #333;
            }
            h1, h2, h3 {
                color: #4dabf7;
            }
            h1 {
                border-bottom-color: #4dabf7;
            }
            h2 {
                border-left-color: #69db7c;
            }
            .invert-demo {
                background: #2d2d2d;
                border-color: #444;
            }
            .invert-demo .box {
                background: #4dabf7;
                color: #000;
            }
            .code-block {
                background: #0d0d0d;
                border: 1px solid #333;
            }
            .reference-table th {
                background: #4dabf7;
                color: #000;
            }
            .reference-table td {
                border-color: #444;
            }
            .reference-table tr:nth-child(even) {
                background: #1a1a1a;
            }
            button {
                background: #4dabf7;
                color: #000;
            }
            @media (hover: hover) {
                button:hover {
                    background: #ff6b6b;
                    color: #000;
                }
            }
            .card {
                background: #1a1a1a;
                border-color: #444;
            }
            /* Re-invert images so they look normal */
            img, video {
                filter: invert(1);
            }
            .tooltip-text {
                background: #fff;
                color: #000;
            }
            .tooltip-text::after {
                border-top-color: #fff;
            }
            .note {
                color: #adb5bd;
            }
            .highlight {
                background: #4dabf7;
                color: #000;
            }
        }

        /* ====== DETECTION CARDS ====== */
        .detection-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
            margin: 20px 0;
        }

        .detection-card {
            padding: 15px;
            border-radius: 8px;
            text-align: center;
            border: 2px solid #ddd;
            background: #f8f9fa;
            transition: all 0.3s;
        }

        .detection-card .label {
            font-size: 0.85rem;
            color: #666;
            display: block;
            margin-bottom: 5px;
        }

        .detection-card .value {
            font-size: 1.1rem;
            font-weight: bold;
            color: #007bff;
        }

        /* ====== LIVE INDICATOR ====== */
        .live-indicator {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background: #007bff;
            color: white;
            padding: 12px 20px;
            border-radius: 50px;
            font-weight: bold;
            font-size: 0.85rem;
            box-shadow: 0 4px 15px rgba(0,123,255,0.4);
            z-index: 1000;
            transition: all 0.3s;
            display: flex;
            flex-direction: column;
            gap: 3px;
        }

        .live-indicator .detail {
            font-size: 0.75rem;
            opacity: 0.9;
        }

        /* ====== PRACTICAL: NAVIGATION ====== */
        .nav-menu {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            list-style: none;
            padding: 0;
            margin: 15px 0;
        }

        .nav-menu li a {
            display: block;
            padding: 10px 20px;
            background: #007bff;
            color: white;
            text-decoration: none;
            border-radius: 8px;
            transition: all 0.3s;
            font-weight: bold;
        }

        @media (hover: hover) {
            .nav-menu li a:hover {
                background: #28a745;
                transform: translateY(-2px);
                box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
            }
        }

        @media (hover: none) {
            .nav-menu li a:active {
                background: #28a745;
                transform: scale(0.97);
            }
        }

        /* ====== INVERTED COLORS BUTTON ====== */
        .invert-toggle {
            background: #6c5ce7;
            color: white;
            border: none;
            padding: 12px 24px;
            border-radius: 8px;
            font-size: 1em;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s;
            margin: 10px 5px;
        }

        @media (hover: hover) {
            .invert-toggle:hover {
                background: #4a2a9e;
                transform: translateY(-2px);
            }
        }

        /* ====== PRACTICAL: INVERTED IMAGE HANDLING ====== */
        .image-demo {
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
            align-items: center;
            margin: 15px 0;
        }

        .image-demo .img-box {
            width: 200px;
            height: 150px;
            background: linear-gradient(135deg, #007bff, #6c5ce7);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: bold;
            font-size: 1.2rem;
            text-align: center;
            padding: 20px;
        }

        @media (inverted-colors: inverted) {
            .image-demo .img-box {
                filter: invert(1);
            }
        }
    </style>
</head>
<body>

    <h1>hover and inverted-colors Media Features</h1>

    <!-- ====== 1. HOVER DEMO ====== -->
    <section>
        <h2>1. hover</h2>
        <p>Applies styles when the <strong>primary pointing device</strong> can hover over elements.</p>

        <h3>Button Hover</h3>
        <button>Hover or Tap Me!</button>
        <p class="note">On desktop with a mouse, the button turns red on hover. On touch devices, it responds to tap (active state).</p>

        <h3>Card Hover</h3>
        <div class="card">
            <strong>Interactive Card</strong>
            <p>This card lifts up on hover (desktop) or changes on tap (mobile).</p>
        </div>

        <h3>Tooltip Hover</h3>
        <div class="tooltip-container">
            <button>Hover for tooltip</button>
            <span class="tooltip-text">This is a tooltip!</span>
        </div>
        <p class="note">Tooltips only appear on devices that can hover.</p>

        <div class="code-block">
            /* Hover effect only for devices that can hover */
            @media (hover: hover) {
                button:hover {
                    background-color: #dc3545;
                    transform: translateY(-2px);
                }
            }

            /* Touch-friendly alternative */
            @media (hover: none) {
                button:active {
                    background-color: #dc3545;
                    transform: scale(0.98);
                }
            }
        </div>
    </section>

    <!-- ====== 2. INVERTED-COLORS DEMO ====== -->
    <section>
        <h2>2. inverted-colors</h2>
        <p>Applies styles when the system uses an <strong>inverted color scheme</strong>.</p>

        <div class="invert-demo">
            <h3>Inverted Colors Demo</h3>
            <p>This box adapts to inverted colors mode:</p>
            <div class="box">
                I adapt to inverted colors!
            </div>
            <p class="note">Enable inverted colors in your OS accessibility settings to see the changes.</p>
        </div>

        <h3>Image Handling in Inverted Mode</h3>
        <div class="image-demo">
            <div class="img-box">๐Ÿ–ผ๏ธ Image</div>
            <p>Images are re-inverted with <code>filter: invert(1)</code> so they look normal in inverted mode.</p>
        </div>

        <div class="code-block">
            /* Inverted colors mode */
            @media (inverted-colors: inverted) {
                body {
                    background: #000;
                    color: #fff;
                }
                section {
                    background: #1a1a1a;
                }
                /* Re-invert images so they look normal */
                img, video {
                    filter: invert(1);
                }
            }
        </div>
    </section>

    <!-- ====== 3. DETECTION SUMMARY ====== -->
    <section>
        <h2>3. Your Device's Capabilities</h2>
        <p>Below is a live detection of your device's capabilities.</p>

        <div class="detection-grid">
            <div class="detection-card" id="hover-hover">
                <span class="label">hover: hover</span>
                <span class="value" id="hover-hover-value">Detecting...</span>
            </div>
            <div class="detection-card" id="hover-none">
                <span class="label">hover: none</span>
                <span class="value" id="hover-none-value">Detecting...</span>
            </div>
            <div class="detection-card" id="any-hover-hover">
                <span class="label">any-hover: hover</span>
                <span class="value" id="any-hover-hover-value">Detecting...</span>
            </div>
            <div class="detection-card" id="invert-none">
                <span class="label">inverted-colors: none</span>
                <span class="value" id="invert-none-value">Detecting...</span>
            </div>
            <div class="detection-card" id="invert-inverted">
                <span class="label">inverted-colors: inverted</span>
                <span class="value" id="invert-inverted-value">Detecting...</span>
            </div>
        </div>

        <div class="code-block">
            /* Detect hover capability */
            @media (hover: hover) { /* Primary device can hover */ }
            @media (hover: none) { /* Primary device cannot hover */ }

            /* Detect any hover capability */
            @media (any-hover: hover) { /* Any device can hover */ }

            /* Detect inverted colors */
            @media (inverted-colors: none) { /* Normal colors */ }
            @media (inverted-colors: inverted) { /* Inverted colors */ }
        </div>
    </section>

    <!-- ====== 4. PRACTICAL EXAMPLE: NAVIGATION ====== -->
    <section>
        <h2>4. Practical Example: Hover-Aware Navigation</h2>
        <p>A navigation menu that works well on both desktop and touch devices.</p>

        <ul class="nav-menu">
            <li><a href="#">๐Ÿ  Home</a></li>
            <li><a href="#">๐Ÿ“„ About</a></li>
            <li><a href="#">โš™๏ธ Services</a></li>
            <li><a href="#">๐Ÿ“ž Contact</a></li>
        </ul>

        <div class="code-block">
            /* Desktop: hover effect */
            @media (hover: hover) {
                .nav-menu a:hover {
                    background: #28a745;
                    transform: translateY(-2px);
                    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
                }
            }

            /* Touch: active effect */
            @media (hover: none) {
                .nav-menu a:active {
                    background: #28a745;
                    transform: scale(0.97);
                }
            }
        </div>
    </section>

    <!-- ====== 5. REFERENCE TABLES ====== -->
    <section>
        <h2>5. Reference Tables</h2>

        <h3>hover Values</h3>
        <table class="reference-table">
            <tr>
                <th>Value</th>
                <th>Description</th>
                <th>Typical Devices</th>
            </tr>
            <tr>
                <td><code>none</code></td>
                <td>Primary input cannot hover</td>
                <td>Touch screens, phones, tablets</td>
            </tr>
            <tr>
                <td><code>hover</code></td>
                <td>Primary input can hover</td>
                <td>Desktop with mouse, laptop with trackpad</td>
            </tr>
        </table>

        <h3>hover vs any-hover</h3>
        <table class="reference-table">
            <tr>
                <th>Feature</th>
                <th>Description</th>
            </tr>
            <tr>
                <td><code>hover</code></td>
                <td>Primary pointing device's hover capability</td>
            </tr>
            <tr>
                <td><code>any-hover</code></td>
                <td>Any pointing device's hover capability</td>
            </tr>
        </table>

        <h3>inverted-colors Values</h3>
        <table class="reference-table">
            <tr>
                <th>Value</th>
                <th>Description</th>
            </tr>
            <tr>
                <td><code>none</code></td>
                <td>Colors are displayed normally (default)</td>
            </tr>
            <tr>
                <td><code>inverted</code></td>
                <td>Display uses an inverted color scheme</td>
            </tr>
        </table>

        <h3>Detection Scenarios</h3>
        <table class="reference-table">
            <tr>
                <th>Device</th>
                <th>hover</th>
                <th>any-hover</th>
            </tr>
            <tr>
                <td>Desktop with mouse</td>
                <td><code>hover</code></td>
                <td><code>hover</code></td>
            </tr>
            <tr>
                <td>Mobile phone (touch)</td>
                <td><code>none</code></td>
                <td><code>none</code></td>
            </tr>
            <tr>
                <td>Tablet with stylus</td>
                <td><code>none</code></td>
                <td><code>hover</code></td>
            </tr>
            <tr>
                <td>Laptop with touchscreen</td>
                <td><code>hover</code></td>
                <td><code>hover</code></td>
            </tr>
            <tr>
                <td>Tablet with Bluetooth mouse</td>
                <td><code>none</code></td>
                <td><code>hover</code></td>
            </tr>
        </table>
    </section>

    <!-- ====== 6. BEST PRACTICES ====== -->
    <section>
        <h2>6. Best Practices</h2>

        <div style="background: #d4edda; padding: 20px; border-radius: 8px; border-left: 4px solid #28a745;">
            <h3 style="margin-top: 0; color: #155724;">โœ… Do This:</h3>
            <ul>
                <li>Use <code>@media (hover: hover)</code> to apply hover effects only when they work</li>
                <li>Provide <code>:active</code> alternatives for touch devices</li>
                <li>Use <code>@media (inverted-colors: inverted)</code> to ensure readability in inverted mode</li>
                <li>Re-invert images with <code>filter: invert(1)</code> in inverted mode</li>
                <li>Test with actual touch devices and screen readers</li>
                <li>Combine <code>hover</code> with <code>any-hover</code> for comprehensive detection</li>
            </ul>
        </div>

        <div style="background: #f8d7da; padding: 20px; border-radius: 8px; border-left: 4px solid #dc3545; margin-top: 15px;">
            <h3 style="margin-top: 0; color: #721c24;">โŒ Don't Do This:</h3>
            <ul>
                <li>Don't rely solely on hover for critical functionality</li>
                <li>Don't forget that touch devices trigger <code>:hover</code> accidentally</li>
                <li>Don't ignore inverted colors โ€” it affects users with visual impairments</li>
                <li>Don't assume all desktops have a mouse (touchscreen laptops exist)</li>
                <li>Don't use hover effects without touch alternatives</li>
            </ul>
        </div>
    </section>

    <!-- ====== LIVE INDICATOR ====== -->
    <div class="live-indicator" id="live-indicator">
        <span id="indicator-text">Detecting...</span>
    </div>

    <!-- ====== SCRIPT FOR DETECTION ====== -->
    <script>
        function updateIndicators() {
            // Hover detection
            const hoverHover = document.getElementById('hover-hover');
            const hoverNone = document.getElementById('hover-none');
            const anyHoverHover = document.getElementById('any-hover-hover');

            if (window.matchMedia('(hover: hover)').matches) {
                hoverHover.querySelector('.value').textContent = 'Supported โœ…';
                hoverHover.style.background = '#d4edda';
                hoverHover.style.borderColor = '#28a745';
                hoverHover.querySelector('.value').style.color = '#28a745';

                hoverNone.querySelector('.value').textContent = 'Not applicable';
                hoverNone.style.background = '#e9ecef';
                hoverNone.style.borderColor = '#6c757d';
                hoverNone.querySelector('.value').style.color = '#6c757d';
            } else {
                hoverNone.querySelector('.value').textContent = 'Active โœ…';
                hoverNone.style.background = '#fff3cd';
                hoverNone.style.borderColor = '#ffc107';
                hoverNone.querySelector('.value').style.color = '#856404';

                hoverHover.querySelector('.value').textContent = 'Not supported';
                hoverHover.style.background = '#e9ecef';
                hoverHover.style.borderColor = '#6c757d';
                hoverHover.querySelector('.value').style.color = '#6c757d';
            }

            if (window.matchMedia('(any-hover: hover)').matches) {
                anyHoverHover.querySelector('.value').textContent = 'Supported โœ…';
                anyHoverHover.style.background = '#d4edda';
                anyHoverHover.style.borderColor = '#28a745';
                anyHoverHover.querySelector('.value').style.color = '#28a745';
            } else {
                anyHoverHover.querySelector('.value').textContent = 'Not supported';
                anyHoverHover.style.background = '#e9ecef';
                anyHoverHover.style.borderColor = '#6c757d';
                anyHoverHover.querySelector('.value').style.color = '#6c757d';
            }

            // Inverted colors detection
            const invertNone = document.getElementById('invert-none');
            const invertInverted = document.getElementById('invert-inverted');

            if (window.matchMedia('(inverted-colors: inverted)').matches) {
                invertInverted.querySelector('.value').textContent = 'Active โœ…';
                invertInverted.style.background = '#fff3cd';
                invertInverted.style.borderColor = '#ffc107';
                invertInverted.querySelector('.value').style.color = '#856404';

                invertNone.querySelector('.value').textContent = 'Not active';
                invertNone.style.background = '#e9ecef';
                invertNone.style.borderColor = '#6c757d';
                invertNone.querySelector('.value').style.color = '#6c757d';
            } else {
                invertNone.querySelector('.value').textContent = 'Active (default) โœ…';
                invertNone.style.background = '#d4edda';
                invertNone.style.borderColor = '#28a745';
                invertNone.querySelector('.value').style.color = '#28a745';

                invertInverted.querySelector('.value').textContent = 'Not active';
                invertInverted.style.background = '#e9ecef';
                invertInverted.style.borderColor = '#6c757d';
                invertInverted.querySelector('.value').style.color = '#6c757d';
            }

            // Live indicator
            const indicator = document.getElementById('indicator-text');
            const hasHover = window.matchMedia('(hover: hover)').matches;
            const isInverted = window.matchMedia('(inverted-colors: inverted)').matches;

            let text = '';
            if (hasHover) text += '๐Ÿ–ฑ๏ธ Hover: Yes';
            else text += '๐Ÿ‘† Hover: No (Touch)';

            if (isInverted) text += ' | ๐Ÿ”„ Inverted: Yes';
            else text += ' | ๐ŸŽจ Inverted: No';

            indicator.textContent = text;

            // Update live indicator color
            const liveIndicator = document.getElementById('live-indicator');
            if (isInverted) {
                liveIndicator.style.background = '#ffc107';
                liveIndicator.style.color = '#333';
            } else if (hasHover) {
                liveIndicator.style.background = '#007bff';
                liveIndicator.style.color = 'white';
            } else {
                liveIndicator.style.background = '#28a745';
                liveIndicator.style.color = 'white';
            }
        }

        window.addEventListener('load', updateIndicators);

        // Listen for changes
        window.matchMedia('(hover: hover)').addEventListener('change', updateIndicators);
        window.matchMedia('(inverted-colors: inverted)').addEventListener('change', updateIndicators);

        updateIndicators();
    </script>

</body>
</html>

Quick Reference

FeatureDescriptionValues
hoverPrimary device can hovernone, hover
inverted-colorsSystem uses inverted colorsnone, inverted

hover Values

ValueDescriptionTypical Devices
noneCannot hoverTouch screens, phones, tablets
hoverCan hoverDesktop with mouse, laptop with trackpad

hover vs any-hover

FeatureDescription
hoverPrimary pointing device’s hover capability
any-hoverAny pointing device’s hover capability

inverted-colors Values

ValueDescription
noneColors are displayed normally (default)
invertedDisplay uses an inverted color scheme

Best Practices

โœ… Do This:

/* Only apply hover effects when hover is possible */
@media (hover: hover) {
    button:hover {
        background-color: #dc3545;
        transform: translateY(-2px);
    }
}

/* Provide touch-friendly alternatives */
@media (hover: none) {
    button:active {
        background-color: #dc3545;
        transform: scale(0.98);
    }
}

/* Handle inverted colors mode */
@media (inverted-colors: inverted) {
    body {
        background: #000;
        color: #fff;
    }
    /* Re-invert images */
    img, video {
        filter: invert(1);
    }
}

โŒ Don’t Do This:

/* Don't apply hover effects unconditionally */
button:hover {
    background: red;
    /* On touch devices, this triggers on tap and sticks! */
}

/* Don't forget touch alternatives */
.menu-item:hover .submenu {
    display: block;
    /* Won't work on touch devices! */
}

/* Don't ignore inverted colors */
body {
    background: white;
    color: black;
    /* May be unreadable if user has inverted colors on */
}

Pro Tip: hover is essential for input-aware design. Always wrap hover effects in @media (hover: hover) โ€” otherwise, touch devices will trigger hover styles on tap, and they’ll “stick” until you tap elsewhere. Provide :active alternatives for touch devices. inverted-colors is crucial for accessibility โ€” users with visual impairments may enable inverted colors. Re-invert images with filter: invert(1) so they look normal, and ensure your text remains readable in inverted mode!


Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!