Removing Gloss Effect on <select> Elements in Safari: A Deep Dive into CSS -webkit-appearance

Dec 02, 2025 · Programming · 11 views · 7.8

Keywords: CSS | Safari | Form Styling

Abstract: This article explores methods to eliminate the default gloss effect on <select> elements in Safari on macOS and iOS. By analyzing the CSS property -webkit-appearance: none;, it explains how to remove gloss while maintaining custom styles, and addresses side effects like disappearing dropdown arrows. With code examples, it provides cross-browser compatible solutions for achieving flat design aesthetics.

Problem Context and Phenomenon Analysis

In Safari on macOS and iOS devices, <select> elements automatically generate a gloss overlay when a background color is applied, a visual effect not commonly seen in other operating systems or browsers. For instance, when developers attempt to set a custom background color for dropdown menus, as shown in the following CSS code:

select {
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    border-radius: 3px;
    padding: 3px 6px;
    margin: 10px 0 7px;
    width: 250px;
    background-color: #BD2786;
    color: white;
    letter-spacing: -.04em;
    font-weight: bold;
    border: 0;
}

Despite the background color being correctly applied, the gloss layer persists, preventing the desired solid-color flat design. This phenomenon stems from Safari's unique rendering mechanism for default form element styles.

Core Solution: The -webkit-appearance Property

The key to eliminating the gloss effect lies in using the CSS property -webkit-appearance: none;. This property overrides the browser's default control appearance, allowing developers to fully customize styles. When applied to <select> elements, it removes all native visual effects, including gloss, as demonstrated in this code:

select {
    -webkit-appearance: none;
    /* other custom styles */
}

This property disables the WebKit engine's default rendering behavior, reverting the element to a base state and thereby eliminating gloss. However, it is important to note that it also removes the dropdown arrow icon, which may impact user experience.

Handling Side Effects and Cross-Browser Compatibility

Since -webkit-appearance: none; hides the dropdown arrow, developers must manually add custom arrows to maintain functionality. A common solution involves using CSS background images with Base64-encoded SVG data, enabling arrow icons without external resources. The following example demonstrates a cross-browser compatible implementation:

select {
    background: url(data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0Ljk1IDEwIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6IzQ0NDt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPmFycm93czwvdGl0bGU+PHJlY3QgY2xhc3M9ImNscy0xIiB3aWR0aD0iNC45NSIgaGVpZ2h0PSIxMCIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxLjQxIDQuNjcgMi40OCAzLjE4IDMuNTQgNC42NyAxLjQxIDQuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iMy41NCA1LjMzIDIuNDggNi44MiAxLjQxIDUuMzMgMy41NCA1LjMzIi8+PC9zdmc+) no-repeat 95% 50%;
    -moz-appearance: none; 
    -webkit-appearance: none; 
    appearance: none;
    height: 30px; 
    width: 100px;
    padding: 5px;
}

This code ensures compatibility with Firefox and other browsers through the -moz-appearance and appearance properties. The SVG data in the background property defines the arrow icon, positioned to the right and centered. To set a background color simultaneously, append it to the background value, e.g., ... no-repeat 95% 50%, #BD2786;.

Implementation Steps and Best Practices

To completely remove the gloss effect on <select> elements in Safari, follow these steps:

  1. Apply -webkit-appearance: none; to remove default gloss and styles.
  2. Add -moz-appearance: none; and appearance: none; for cross-browser consistency.
  3. Integrate custom arrow icons using CSS background properties to avoid loss of functionality.
  4. Combine with other style attributes (e.g., border, padding) to refine the design and achieve a flat effect.

This approach allows developers full control over the appearance of <select> elements, aligning with modern web design trends while maintaining cross-platform compatibility.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.