
Orientation refers to whether content is displayed in portrait mode, which is taller than it is wide, or landscape mode, which is wider than it is tall. On the web, orientation becomes important in a few common scenarios: printing a web page, saving it as a PDF, viewing it on a rotating phone or tablet, or designing layouts that adapt to different screen shapes. This guide explains how to change the orientation of a web page as a user and how developers can control and respond to orientation with CSS and JavaScript.
Design Adaptive Web Experiences With AAMAX.CO
A great website adapts seamlessly whether a visitor holds a phone upright, rotates a tablet, or prints a page for reference. AAMAX.CO is a full-service digital marketing company providing web development, digital marketing, and SEO services worldwide. Their developers create orientation-aware, responsive interfaces and print-friendly layouts as part of their web application development services. They ensure users enjoy a consistent experience no matter how they view your content.
Changing Orientation When Printing in Chrome
- Open the web page and press Ctrl and P on Windows or Command and P on Mac.
- In the print preview panel, find the Layout option.
- Select Portrait or Landscape.
- Preview the result, adjust margins or scale if needed, and click Print or choose Save as PDF as the destination.
If the Layout option is missing, the website may have set a fixed page orientation using CSS, which overrides the browser control.
Changing Orientation in Microsoft Edge
Edge's print dialog works similarly to Chrome's. Open the print dialog, locate the Layout or Orientation setting, and choose Landscape or Portrait. Edge also lets you adjust scale and margins to fit wide tables or images onto the page.
Changing Orientation in Firefox
In Firefox, open the print dialog and choose Portrait or Landscape under Orientation. Firefox also offers a Simplify page option that removes clutter before printing, which can make landscape layouts easier to read.
Changing Orientation in Safari
In Safari on Mac, open the File menu and choose Print. If the full options are not visible, click Show Details. Use the orientation icons to switch between portrait and landscape, then print or save as a PDF.
Rotating Web Pages on Mobile Devices
On phones and tablets, the browser follows the device's orientation. Rotate your device to switch between portrait and landscape. If the page does not rotate, check that rotation lock is turned off in your device's control center or quick settings panel. Landscape mode is helpful for viewing wide tables, charts, and videos.
Controlling Print Orientation With CSS
Developers can specify the preferred print orientation using the @page rule:
@media print {
@page {
size: landscape;
margin: 1cm;
}
}This is useful for invoices, reports, and dashboards that contain wide tables. Use it carefully, since forcing an orientation removes the user's ability to choose. You can also apply named pages in modern browsers to set different orientations for specific sections.
Creating Print-Friendly Styles
Beyond orientation, a good print stylesheet improves readability on paper:
- Hide navigation menus, ads, and interactive elements that are not useful in print.
- Use readable font sizes and high-contrast colors.
- Prevent awkward page breaks inside tables and images with break-inside: avoid.
- Show full URLs after links so readers can find referenced pages.
Responding to Device Orientation With CSS
CSS media queries can detect orientation and adjust layouts accordingly:
@media (orientation: landscape) {
.gallery {
grid-template-columns: repeat(4, 1fr);
}
}
@media (orientation: portrait) {
.gallery {
grid-template-columns: repeat(2, 1fr);
}
}In many cases, width-based media queries are more reliable than orientation queries, but orientation queries are helpful for media-rich interfaces like galleries, games, and video players.
Detecting Orientation With JavaScript
JavaScript can detect orientation changes for more advanced behavior:
const query = window.matchMedia("(orientation: landscape)");
function handleOrientation(event) {
document.body.classList.toggle("is-landscape", event.matches);
}
query.addEventListener("change", handleOrientation);
handleOrientation(query);Web apps running in full-screen mode can also request a specific orientation using the Screen Orientation API, which is useful for games and media applications on supported devices.
Accessibility Considerations
Accessibility guidelines recommend that content should not be restricted to a single display orientation unless it is essential. Some users mount devices in a fixed position, such as on a wheelchair, and cannot rotate them. Design layouts that work in both orientations whenever possible.
Saving a Web Page as a Landscape PDF
Landscape PDFs are ideal for sharing wide dashboards, spreadsheets, and timelines. In any major browser, open the print dialog, choose Save as PDF or Microsoft Print to PDF as the destination, select Landscape, and adjust the scale until the content fits the page width. Enabling background graphics preserves colors and charts. Preview the result before saving, and if the layout still looks cramped, reduce margins or the scale percentage slightly.
Conclusion
Changing the orientation of a web page is simple for users through browser print dialogs and device rotation. Developers can control print orientation with the @page rule, adapt layouts using orientation media queries, and respond with JavaScript when needed. By supporting both portrait and landscape views thoughtfully, you create a flexible, accessible experience for every visitor.
