Basics
The handful of CSS lines that stop a web app from feeling like a web page on a phone — zoom, text selection, long press, tap highlight, overscroll, scrollbars, viewport height and safe areas.
This section is for one goal: making a web app pass as a native one — an installed PWA, or a web view inside an app shell. A web page on a phone gives itself away in small ways: pinch zoom moves the whole UI, a long press on a tab selects its label, a grey box flashes over every link, scrolling a panel past its end drags the whole page, a fixed footer slides under the browser's toolbar. Each fix is a line or two of CSS.
Several of these break conventions a regular website should keep, and that's the point — native apps break them too. Each section shows how, and what you give up, so the trade is a decision rather than an accident. Don't apply them to a content site like this one.
Zoom
Native apps don't pinch-zoom. On the web there are two parts to switching it off, and one of them doesn't work everywhere.
import type { Viewport } from "next";
export const viewport: Viewport = {
maximumScale: 1,
userScalable: false,
};Browsers that honor the viewport meta tag stop pinch zoom with this. Safari
on iOS doesn't, on purpose: since iOS 10 it "allows the user to pinch zoom on
every page" and ignores user-scalable, min-scale and max-scale
(WebKit blog, 2017). What people reach for on iOS:
touch-action: pan-x pan-yon the root — the value that leaves outpinch-zoom. MDN describes the values but not Safari's support for this combination.- Cancelling Safari's proprietary
gesturestartevent. MDN documents the event as non-standard and doesn't say whether cancelling it stops zoom.
Both are workarounds against a deliberate browser decision, so test them on the iOS versions you support and expect them to stop working.
What you give up. Pinch zoom is how people with low vision read small
text; WCAG 1.4.4 asks for text that scales to 200%. Native apps get away with
no zoom because they follow the system text size (Dynamic Type on iOS). If
you block zoom, give that back: size text in rem, offer a text-size setting,
or use WebKit's Dynamic Type text styles, such as font: -apple-system-body.
Unwanted zoom
Even with zoom allowed, the zoom that feels most "web" is the kind nobody asked for. It has three separate causes, and fixing them costs nothing:
| Unwanted zoom | Fix |
|---|---|
| Double-tapping a button zooms the page | touch-action: manipulation on controls |
| Focusing an input zooms in on iOS | input font size of at least 16px |
| Text gets bigger in landscape | text-size-adjust: 100% (plus -webkit- for Safari) |
touch-action: manipulation keeps panning and pinch zoom but drops
double-tap zoom, which also lets the browser fire click without waiting to
see whether a second tap follows.
Safari on iPhone enlarges text when the phone turns to landscape (not on
iPad, where Apple's default for -webkit-text-size-adjust is already
none). 100% turns that off and is equivalent to none per the CSS draft;
Safari still needs the -webkit- prefix.
iOS zooms into any focused input whose text is smaller than 16px. shadcn's
Input uses text-base md:text-sm for exactly this reason: 16px on phones,
14px from the md breakpoint up. Keep that when you restyle it.
Text selection
Double-clicking or long-pressing a control's label selects it, and on a
phone that opens selection handles and a copy menu over your UI. Native
<button> and <a> mostly resist this on desktop; anything built from other
elements doesn't — like this segmented control made of radio inputs and
labels. Double-click a segment (or long-press it on a phone), then turn the
fix on:
Order #1042 · 221B Baker Street, London NW1 6XE
Selected: nothing
.app-control {
-webkit-user-select: none;
user-select: none;
}An app can go further and put it on body, which is what many hybrid apps
do: native UI text isn't selectable either. What you give up: people copy
addresses, order numbers, error messages and prices, and with selection off
everywhere they have to retype them. The middle ground is controls only —
buttons, tabs, segmented controls, toolbars, list rows that navigate — and
user-select: text back on content, like the order line in the demo.
shadcn's Button and Label already include select-none.
Long press
Holding a finger down does something different depending on what's under it:
| Under the finger | iOS Safari | Android Chrome |
|---|---|---|
| Link | link preview and a callout sheet | menu: open in new tab, copy link, … |
| Image | sheet to save or share the image | menu to download or share the image |
| Text | selection handles and a magnifier | selection handles |
Text selection is the user-select from the previous section. On iOS, the
link and image sheets are a separate property:
.app-nav a {
-webkit-touch-callout: none;
}A native app has no link previews at all, so turning the callout off
everywhere matches it. What you give up: on content links and images,
the sheet is how people share a link or save a photo. Android has no CSS
equivalent; its menu is tied to the contextmenu event as far as
we know, so test preventDefault() there on a device before relying on it.
Long press as a gesture of your own — hold a list item to open its actions — is a separate pattern: a timer (UIKit's default is 0.5 s), a movement threshold so scrolling doesn't trigger it (UIKit allows 10 points), swallowing the click that follows, and a visible way to reach the same actions. Apple's guidance for context menus: "Always make context menu items available in the main interface, too."
Tap highlight
Mobile WebKit and Chromium paint a translucent box over a link or button while it's touched. It's the browser's default pressed state, so if you remove it, replace it:
.app-row {
-webkit-tap-highlight-color: transparent;
touch-action: manipulation;
}
.app-row:active {
background: rgb(0 0 0 / 0.1);
}The demo only differs on a touch screen. Without a pressed state, a tap shows no response until the next screen appears, which on a slow network reads as a missed tap — see Animations for press feedback.
On iOS, :active may not apply at all. Apple's Safari Web Content Guide
(archived, last updated 2016) says mouse events arrive so fast "the down or
active state is never received", so :active fires only when there is a
touch event on the element. One passive listener on the document is the usual
fix:
document.addEventListener("touchstart", () => {}, { passive: true });React apps may already be covered, since React attaches its touch listeners to the root element. Either way, check the pressed state on a real iPhone.
Overscroll
When a scrollable panel hits its end, the browser passes the remaining scroll to the page behind it (scroll chaining). In a chat panel, a sheet or a side menu, that drags the whole page. Scroll to the end of the list with a mouse wheel or a finger:
- Order #1040 shipped
- Courier is 1 min away
- Payment of €7.00 received
- Order #1043 shipped
- Courier is 4 min away
- Payment of €17.50 received
- Order #1046 shipped
- Courier is 7 min away
- Payment of €28.00 received
- Order #1049 shipped
- Courier is 10 min away
- Payment of €38.50 received
- Order #1052 shipped
- Courier is 13 min away
- Payment of €49.00 received
- Order #1055 shipped
- Courier is 16 min away
- Payment of €59.50 received
- Order #1058 shipped
- Courier is 19 min away
Page scrolled while you scrolled the list: 0 px
| Value | Scroll chaining | Bounce at the edge |
|---|---|---|
auto | yes | yes |
contain | no | yes |
none | no | no |
Use contain on inner scrollers. It still allows the bounce, on both axes —
so a list that only scrolls vertically wobbles sideways on a trackpad. Set
the axes separately: overscroll-behavior-y: contain keeps the vertical
bounce, overscroll-behavior-x: none removes the horizontal one.
On the page itself, none makes the shell feel fixed in place like a native
screen. What you give up: the
browser's pull-to-refresh and the edge bounce — so the app needs its own
refresh, or people have no way to reload a stuck screen in an installed PWA,
which has no reload button.
Scrollbars
On phones, scrollbars are already native: a thin indicator that appears while scrolling and takes no space. On a desktop or a tablet with a mouse, an installed app gets the platform's classic scrollbars, which look like a web page inside an app window. To hide them:
.app-scroller {
scrollbar-width: none;
}scrollbar-width is Baseline since December 2024; the element "will still
be scrollable". The old ::-webkit-scrollbar { display: none } is only
needed for Safari versions before that, and browsers ignore it once
scrollbar-width is set.
What you give up. MDN puts it plainly: "Avoid using none, as hiding a
scrollbar negatively impacts accessibility." Wheel, trackpad, touch and
keyboard still scroll, but a mouse user loses the visible position in the
list and the thumb to drag, and nothing hints that a short panel scrolls at
all. The middle ground keeps the scrollbar but makes it quiet:
.app-scroller {
scrollbar-width: thin;
scrollbar-color: rgb(0 0 0 / 0.3) transparent;
}scrollbar-color (Baseline since December 2025) takes the thumb colour, then
the track; keep enough contrast between the thumb and what's behind it.
Viewport height
On phones, the address bar shrinks and grows while scrolling, so "the height
of the screen" has three answers. vh is the largest one, which is why
height: 100vh hides the bottom of the screen behind the toolbar.
| Unit | Viewport | Use for |
|---|---|---|
svh | smallest, toolbars expanded | screens that must fit: an app shell |
lvh | largest, toolbars retracted (same as vh) | backgrounds that should never show gaps |
dvh | current, changes while scrolling | when it must track the toolbar |
Prefer svh. dvh changes while the user scrolls, so anything sized with it
moves as the toolbar shows and hides.
Safe areas
On phones with a notch, rounded corners or a home indicator, the browser
keeps the page inside a safe rectangle by default. An app shell that wants to
paint edge to edge opts out with viewport-fit=cover — and then has to pad
its own content:
import type { Viewport } from "next";
export const viewport: Viewport = {
viewportFit: "cover",
};.tab-bar {
padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}
.app-header {
padding-top: env(safe-area-inset-top);
}The insets are 0 on a plain rectangular screen, so max() keeps your normal
padding there and grows it only where the home indicator sits. Without
viewport-fit=cover they're 0 everywhere — the browser is already keeping
you inside the safe area.
All together
html {
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
}
.app-shell {
min-height: 100svh;
}
.app-control {
-webkit-user-select: none;
user-select: none;
-webkit-tap-highlight-color: transparent;
touch-action: manipulation;
}
.app-nav a {
-webkit-touch-callout: none;
}
.app-scroller {
overscroll-behavior: contain;
}
.app-tab-bar {
padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}
input,
select,
textarea {
font-size: max(16px, 1rem);
}Sources
- MDN:
viewport meta,
touch-action,user-select,-webkit-touch-callout,-webkit-tap-highlight-color,text-size-adjust,overscroll-behavior,scrollbar-width,scrollbar-color, viewport units,env() - WebKit, New Interaction Behaviors in iOS 10 (2017); Using the System Font in Web Content (2015)
- MDN,
GestureEvent - W3C, Understanding SC 1.4.4 Resize Text
- Apple:
minimumPressDuration,allowableMovement, HIG: Context menus - Apple, Safari Web Content Guide: Customizing Style Sheets (archived, 2016)
- CSS WG, CSS Mobile Text Size Adjustment Module Level 1 (Editor's Draft)
- Kilian Valkhof, Your CSS reset needs text-size-adjust (probably) (2022)