How should a website respond when a phone changes orientation?

A website should reflow when a phone changes orientation, preserve the user’s task and keep the focused control visible. CSS width, height and aspect-ratio queries can handle most layout changes without JavaScript. Treat rotation as a new viewport shape, not as a request to reload the page.
Use flexible grids and content-based breakpoints because landscape phones are short and relatively wide. A desktop navigation pattern may still be unsuitable when the available height is limited. Test width and height because the orientation keyword alone misses crowded short screens, and keep tap targets large enough when more items fit on one row.
@media (orientation: landscape) and (max-height: 32rem) {
.hero {
min-height: auto;
padding-block: 1.5rem;
}
.sticky-promo {
position: static;
}
}
Do not discard form input, close a media player or return a carousel to its first slide during rotation. Components should recalculate geometry from their current state. ResizeObserver can update a component whose container changes, while a window resize listener may be enough for a small layout-specific measurement.
Media and canvas elements need special checks. A video can retain playback while its box changes. Canvas content may need its backing resolution recalculated, but avoid clearing user drawings. Maps, charts and virtualized lists may expose a resize method that should run after the new layout settles.
Test rotation with the keyboard open, a modal displayed, content scrolled midway and zoom enabled. Look for clipped fixed bars, stale pixel measurements and jumps to the top. The page should remain usable if orientation events arrive more than once or the browser reports intermediate dimensions during the physical turn.