Explain Codes LogoExplain Codes Logo

How can I change the color of header bar and address bar in the newest Chrome version on Lollipop?

html
responsive-design
meta-tags
browser-compatibility
Anton ShumikhinbyAnton Shumikhin·Aug 28, 2024
TLDR

To swiftly alter the color of Chrome's header and address bar on Android Lollipop, insert the meta tag with the theme-color attribute in the <head>:

<meta name="theme-color" content="#HEX">

Replace #HEX with your chosen hexadecimal color code to observe an immediate shift in Chrome's UI.

Step-by-step application

Incorporating the theme-color tag

Comprehend that a consistent color scheme across your web application and the browser interface, can meaningfully enhance user experience. The meta tag with the name attribute set to theme-color is the instrumental link for this UI transformation.

Dealing with compatibility issues

This nifty tag doesn't operate universally. Refer to caniuse.com to verify how well this tool fits into the browser compatibility matrix. Remember, the dark mode can override your chosen theme color.

Different operating environments

In the diverse world of web, different platforms require different approaches. For Windows Phone, apply:

<!-- On a Windows Parade --> <meta name="msapplication-navbutton-color" content="#colorcode">

On its iOS counterpart, employ:

<!-- iStyle --> <meta name="apple-mobile-web-app-status-bar-style" content="style">

Select among default, black or black-translucent options based on your preference. For enabling full screen, go with:

<!-- iFull --> <meta name="apple-mobile-web-app-capable" content="yes">

Perfecting your web app's aesthetics

Enrich your web application by including a 192x192px PNG favicon for a sharper display on Chrome for Android.

Pro-tip: In Chrome settings, use the "Merge Tabs and Apps" option for a harmonious color theme in the task switcher.

Activating your new theme

After inserting the meta tag, refresh your web page to apply your new theme. If updates aren't immediately visible, verify that you're viewing it on a supportive Android device and ensure cache is cleared.

Overtaking dark mode

If your theme is being overridden by dark mode, consider employing media queries or JavaScript to set meta tag's content based on device settings.