The ‘Viewport not set’ error occurs when a webpage is missing the viewport meta tag. This tag is a small piece of code placed inside the <head> section of your HTML. Its job is to tell mobile browsers how they should scale and display your content depending on the screen size.
If the viewport isn’t set, mobile devices will assume the site is designed for a desktop screen. As a result, the page will appear zoomed out, forcing users to pinch, zoom, and scroll horizontally just to read or interact with your site. This creates a frustrating experience, increases bounce rates, and negatively impacts SEO rankings.
Mobile-friendliness: With over half of web traffic coming from mobile devices, ensuring content is responsive is crucial. The viewport tag makes the site adapt smoothly to smaller screens.
Better user experience: A readable, mobile-optimized layout encourages users to stay longer and engage more.
SEO benefits: Google prioritizes mobile-friendly websites in search rankings. Missing a viewport meta tag is flagged as a critical issue in SEO audits.
Every webpage is built with HTML code. The <head> section is at the very top of the file, before the <body> tag.
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Website</title>
<!-- This is where you’ll add the viewport meta tag -->
</head>
<body>
<h1>Welcome to My Website</h1>
</body>
</html>
👉 Look for <head> ... </head> — that’s the part you’ll be editing.
Inside the <head> section, paste the following line of code:
<meta name="viewport" content="width=device-width, initial-scale=1">
Added viewport meta tag to the HTML
What it does:
width=device-width: tells the browser to use the device’s screen width.
initial-scale=1: sets the initial zoom level to 100% (so text and layout look correct).
If you’re working with a content management system (like Shopify, WordPress, etc.), you’ll usually find the <head> inside the theme editor or template files.
Save your changes and publish them.
Run your site through these tools:
Google Search Console - Mobile-Friendly Test: Checks how your site looks on mobile.
PageSpeed Insights: Reports if the viewport tag is missing.
You can also just open your site on your phone — the text and layout should now scale properly.
Sometimes adding the viewport tag doesn’t fully solve the problem. Here are a few things to check:
Conflicting CSS: If your site uses fixed widths in CSS (like width: 1000px;), content may still overflow on small screens. Consider switching to relative units (%, em, rem).
Multiple viewport tags: Having more than one meta viewport tag can confuse the browser. Make sure there’s only one.
Caching issues: If you don’t see changes right away, clear your browser cache or check in an incognito window.
Yes, adding or editing HTML requires some coding knowledge. If you’re not comfortable making these changes yourself, Tapita’s expert team can help. They’ll not only add the viewport meta tag but also check deeper for related issues, such as improper scaling, conflicting CSS rules, or other mobile usability errors.