|
↳ See all 15 articles
/ Documentation /Theme Customization/ How to Remove the White Bars in the Safari Browser on iPhone X and Higher

How to Remove the White Bars in the Safari Browser on iPhone X and Higher

On iPhones with an edge-to-edge display (iPhone X and later), Safari can show bars on the left and right sides of a website when the phone is rotated to landscape. These bars don’t appear in portrait.

Requirements

  • The Astra theme (free version)
  • One of the following to add the code: Astra Pro (Site Builder) or the free Astra Hooks plugin

Why the White Bars Appear

iOS keeps website content inside a “safe area” so it isn’t hidden behind the notch or Dynamic Island, the rounded corners, or the home indicator. In landscape, Safari fills the space outside the safe area with the page’s background color. If the site background is white, these areas show up as white bars beside the content.

iPhone Layout Before

You can read more about “Positioning Content Relative to the Safe Area” at official Apple website.

White Bars iPhone

Extend the Website to Fill the Screen

If you’re looking to remove the white bars, add viewport-fit=cover to the viewport meta tag. This lets the site fill the entire screen instead of only the safe area:

Here is a custom code that you will need to add to your website –

<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">

Your website would look something like this as a result:

iPhone After

As you can see, the white spaces on the left and right sides of the screen were removed.

How To Add Custom Code To Your Website

You can add this code using either of the methods below.

Method 1: Using Site Builder (Astra Pro)

Site Builder is included with Astra Pro. Make sure Astra Pro is installed and activated before following these steps:

  • Go to Astra → Site Builder and select Hooks
screenshot 2026 07 12 215036
screenshot 2026 07 12 220058
  • Give it a name (e.g. “Safari Viewport Fix”) and enable the Code Editor
screenshot 2026 07 12 220255
  • Insert the code in the Code Editor and in the Custom Layout Settings, set the following options:
  • Layout: Hooks
  • Action: wp_head
  • Display On: Entire Website
  • Publish the layout.
screenshot 2026 07 12 221955

Method 2: Using the Astra Hooks Plugin (Free Astra)

If you’re using the Astra theme only without an Astra Pro add-on, you can add this code using the Astra Hooks plugin. Just go to Dashboard > Plugins > Add New, find Astra Hooks, install and activate it.

Once the plugin is activated, follow these steps:

Install Astra Hooks Plugin

Open your Customizer (Dashboard > Appearance > Customize)

In the Customizer, go to Hooks > Header

Astra Hooks Header

Add the code to the wp_head section and Publish.

Add Code to WordPress Header

That’s all!

Expected Outcome

Clear your site cache, open the website in Safari on an iPhone, and rotate it to landscape. The website now extends to both edges of the screen, with no white bars on the sides.

  • If you’d prefer not to add code, setting the site background color to match the website’s main color makes the bars blend in instead of showing as white. It may not work as expected for some sections with different background.

Your website will now look great on iPhone edge-to-edge screens too.

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
Scroll to Top