Unique styling of checkboxes using CSS appears distinctive exclusively on Safari for iPad devices

After trying to customize checkbox styling, I found that they display correctly on most browsers except for Safari on iPad.

My approach involves removing the checkbox appearance and using a span element to simulate it with custom styling.

.container{
            width:300px;
            border:solid 1px lightgrey;
            padding:20px;
        }
        ul, li, label{
           width:100%;
        }

        li{
         
            list-style: none;
            padding:5px;
        }
     
        input[type=checkbox], input[type=checkbox]:checked{
           -webkit-appearance: none;
                -moz-appearance: none;
                    appearance: none;
        }
        input[type=checkbox] + span{
            height:16px;
            width:16px;
            border:solid 1px red;
            color:white;
        }
        input[type=checkbox]:checked + span{
            height:16px;
            width:16px;
            border:solid 1px #4b4b4b;
            background: #4b4b4b;
            color:#ff0000;
            display:flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
            padding-top:1px;
            padding-left:1px;
            font-size:0.75rem; 
        }
       <div class="container">
            <ul>
                <li><label for="option1">Option 1<input id="option1" type=checkbox><span>&#10004</span></label></li>
                <li><label for="option2">Option 2<input id="option2" type=checkbox><span>&#10004</span></label></li>
                <li><label for="option3">Option 3<input id="option3" type=checkbox><span>&#10004</span></label></li>
                <li><label for="option4">Option 4<input id="option4" type=checkbox><span>&#10004</span></label></li>
                <li><label for="option5">Option 5<input id="option5" type=checkbox><span>&#10004</span></label></li>
            </ul>
        </div>

When viewed on Firefox, Chrome, Safari (macOS), and Edge, the checkboxes look like this:

https://i.sstatic.net/9Hp7l.png

The appearance differs on Safari for iPad:

https://i.sstatic.net/UwdkK.png

In iPadOS version 16.2, the color property doesn't apply to the checkboxes. The tick symbol inherits the background color instead. Is there any way to resolve this issue?

Answer №1

It appears that the selected character is considered a dingbat.

In order for IOS Safari to properly display the CSS, it seems necessary to explicitly specify that the character is a dingbat.

The snippet provided in the question includes code where the second span sets the font-family to a dingbat one, resulting in the tick being styled correctly on IOS 15.6.1 on an iPad.

    .container{
        width:50%;
        border:solid 1px lightgrey;
        padding:20px;
    }
    ul, li, label{
        width:100%;
    }
    li{
        list-style: none;
        padding:5px;
    }
    label{
        display:flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    input[type=checkbox], input[type=checkbox]:checked{
       -webkit-appearance: none;
            -moz-appearance: none;
                appearance: none;
    }
    input[type=checkbox] + span{
        height:16px;
        width:16px;
        border:solid 1px red;
        color:white;
    }
    input[type=checkbox]:checked + span{
        height:16px;
        width:16px;
        border:solid 1px #4b4b4b;
        background: #4b4b4b;
        color:#ff0000;
        display:flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        padding-top:1px;
        padding-left:1px;
        font-size:0.75rem; 
    }
    <div class="container">
        <ul>
            <li><label for="option1">Option 1<input id="option1" type=checkbox><span>&#10004</span></label></li>
            <li><label for="option2">Option 2<input id="option2" type=checkbox><span style="font-family: 'Zapf Dingbats';">&#10004;</span></label></li>
            <li><label for="option3">Option 3<input id="option3" type=checkbox><span>&#10004</span></label></li>
            <li><label for="option4">Option 4<input id="option4" type=checkbox><span>&#10004</span></label></li>
            <li><label for="option5">Option 5<input id="option5" type=checkbox><span>&#10004</span></label></li>
        </ul>
    </div>

The solution was inspired by this thread, which addressed a similar issue with a different Unicode character in Safari for iOS.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can you explain the discrepancy between these two CSS statements?

Comparing two CSS combinations: .firstexpression.secondexpression (no space in between) versus .firstexpression .secondexpression (with a space in between) Could you explain the distinction? ...

Running system commands using javascript/jquery

I have been running NodeJS files in the terminal using node filename.js, but now I am wondering if it is possible to execute this command directly from a JavaScript/jQuery script within an HTML page. If so, how can I achieve this? ...

ng-repeat table grouping by date

How can I utilize *ngFor to generate an HTML table grouped by date in columns? Here is an example of a JSON List: [{ "id": "700", "FamilyDesc": "MERCEDES", "model": "Mercedes-BenzClasse A", " ...

Is it Possible for IE9 to Coexist with Rounded Corners and CSS Background Gradients?

Encountering an odd issue in IE9 while attempting to display a background gradient. The approach involves applying multiple classes to a container element. <div class="gradient corners"></div> Here is the CSS being used: .gradient { backgro ...

The tooltip starts to flicker when you hover over it

My tooltip is flickering or blinking when I hover over it. How can I prevent this from happening? http://jsfiddle.net/keshav_1007/en5tcjaw/ - check out the fiddle here $(function() { /*tooltips*/ $('.tooltip').hide(); $('.trigg ...

Positioning child divs using CSS

I am trying to arrange the #inner2 and #inner3 divs to float next to each other while also adjusting to fit perfectly within the #outer div when the browser window size changes. Unfortunately, inner3 is not floating correctly as it should be and is overlap ...

To ensure that any changes made to data are reflected automatically when viewing data in Angular 2

In the process of developing an Angular 2 application, I encountered a scenario that requires special attention. The data displayed on the view is fetched from an API, with certain fields being editable by the user. These modifications can be saved using ...

Switching the orientation of an iPhone on Chrome can lead to content being cut off

Currently, I am conducting testing on an iPhone XS running iOS 15.6.1 The website seems to function properly on iOS Safari (although untested on Android), however, a problem arises when using Chrome and rotating the screen from landscape to portrait mode. ...

When printing, the footer information appears jumbled together

When creating a footer for printing, I am utilizing the following CSS: @media all { .page-break { display: none; } .footer {display: none; } } @media print { .page-break { display: block; page-break-before: always; } .footer {display: bl ...

Is there a way to adjust the size of the canvas element in HTML without compromising quality or resorting to zooming?

I'm currently working on a basic modeling application for the web. The main component of my app is a canvas element that I'm trying to size correctly. However, when I set the height and width using CSS, it scales the entire canvas and compromises ...

Properly extending the functionality of an HTML widget

Understanding HTML and CSS layout is still a mystery to me, so any guidance on what I'm trying to achieve would be greatly appreciated. I am currently developing a JavaScript API for our company's "widget" so that users can integrate it into the ...

Assign a unique ID to each Angular Material checkbox

Presently, I am facing an issue: I am required to generate md-checkboxes from a Database. The implementation is successful using ng-repeat. However, I am encountering difficulties in fetching the data from these checkboxes. Each entry in the Database has ...

Distinction between style and styleClass on a JSF webpage

I recently began navigating a java code base that utilizes the style and styleClass keywords to customize elements within the jsf page. This particular project is built on jsf 2.2. The 'style' keyword is used for applying html attributes like: ...

What is the best way to determine the location of just one element?

I am currently working on a rating application where only the selected circle should remain green, not all of them. $('#rating-container').click(function () { var element = $('#target'); var container = $('#rating-containe ...

When the horizontal scroll is turned off, it also disables the functionality of my mobile-friendly

I came across a helpful post on StackOverflow that suggested using the following code to disable horizontal scrolling: html, body { overflow-x: hidden; } This solution did resolve my issue of horizontal scrolling, but unfortunately it caused problems ...

iOS is not recognizing the <a> tag but is instead honoring the :hover property

Within my list, I have a div element wrapped in an anchor tag. Here is an example of the code: <li> <a href="http://google.com/"> <div id="tease-info"> <div class="inset-img-border fade"></div> <img src=" ...

What is causing the text to not wrap around properly?

I'm currently facing an issue where the text that should not wrap around the image is wrapping, while the text that should be wrapped isn't. This is causing a layout problem in my coding section as shown here: https://i.sstatic.net/2oMn1.png The ...

Why does the Bootstrap Modal only appear on one page and not the other?

Currently, I am working on coding a website with Bootstrap. On one page, I have successfully implemented a modal (check it out here), but on the other page, the modal doesn't seem to show up (here). There is a button on that page for editing ban detai ...

Directive customization through comprehension expressions

Python is where I spend a lot of my time, so I'm really drawn to the comprehension_expression syntax within Angular's ngOptions. However, I would love to see this syntax extend to other inputs, such as with an ng-list. For instance, let's s ...

When the CSS style sheet is not embedded within the HTML document, it fails

I'm facing an issue while trying to apply currency formatting to an HTML table in order to have it display correctly when opened in Excel. Initially, I tried doing this inline and it worked fine, like so: <td style="mso-number-format:$\##&bso ...