Disabling the Device’s Default ‘Dark Mode’ in WordPress

1 year ago

2 min read

Posted by:

Focus

Subscribe to newsletter

By subscribing you agree to with our Privacy Policy.

Share

If you are trying to convert your WordPress website to APK / AAB, you may need to disable the device’s built-in ‘Dark Mode’. The way to do this is quite simple, you just need to add some code to your WordPress CSS file.

Here is the code you need to add in the ‘Customize’ > ‘Additional CSS’ section :

For Firefox:

@media (prefers-color-scheme: dark) {    :root {        color-scheme: light;    }}

For Chrome:

@media (forced-colors: active) {    :root {        color-scheme: light;    }}

And the following code to set light mode as the only color scheme:

:root {    color-scheme: only light;}

Here’s the full code:

/* Firefox */
@media (prefers-color-scheme: dark) {
:root {
color-scheme: light;
}
}

/* Chrome */
@media (forced-colors: active) {
:root {
color-scheme: light;
}
}

:root {
color-scheme: only light;
}

By adding the above code, the built-in ‘Dark Mode’ in Firefox and Chrome on your device will be disabled, setting light mode as the primary color scheme.

Additionally, you need to add the following code to your header. Use the “HTML” widget in Elementor:

<meta name="color-scheme" content="only light">

Of note, be sure to be tested and monitored after application to ensure intended results are achieved and there are no unexpected side effects.

Read more

Video

< 1 min read

How to Get Youtube API and Check Quotas

How to get Youtube API:Go to: https://console.cloud.google.com/apis/dashboard How to check Youtube API Quota:Go to: https://console.cloud.google.com/iam-admin/quotas

Read more

Header

< 1 min read

Header Padding: Conditional HTML

If you want to have conditional padding for your header, give your header the CSS class .mainheader and add an

Read more

Container

< 1 min read

Hide Scroll Bar On ‘Overflow: Auto’ Container

Add this following CSS code to the container: selector {-ms-overflow-style: none; /* IE and Edge / scrollbar-width: none; / Firefox

Read more

Image

< 1 min read

Crop Image To Ratio

To crop image based on ratio, on Elementor’s Image Widget add this CSS: 16:9 Landscape CSS 9:16 Portrait CSS

Read more

See How It Works

Create better websites, faster.

Download the Entire Library

Adaptative, neutrally designed components.

Customer Service

Focus Website

Today, December 3

Hi, there 👋

How can I help you?

Start Chat with:

We use cookie to improve your experience on our site. By using our site you consent cookies.