Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set viewport using meta viewport tag for desktop browsers

Tags:

html

css

I have a client provided website of width 1440 pixels. The client has asked me to set the viewport to 1440 pixels using for desktop browsers so that for screens smaller than 1440 pixels do no show a scrollbar.

It does work for mobile, ipad devices where we can can set the viewport using this. Does this work for desktop browsers as well?

I tried setting the viewport using this but could see a scrollbar. Could someone provide some thoughts on this.

code:

   <!DOCTYPE html>
     <html>
     <head>
     <meta name="viewport" content="width=1440">

     </head>
    <body>
<div style="width:1440px;">
    test content
 </div>


 </body>
</html>

Thanks

like image 481
Apurva T Avatar asked Sep 14 '16 08:09

Apurva T


People also ask

Where do I put a viewport meta tag?

Generally, meta elements (including viewport) should be placed in the document's <head> . CSS rules should either be added to a CSS stylesheet and referenced with a <link> element or, if you're not using stylesheets for some reason, in a <style> element (also in the document's <head> ).

What does the viewport meta tag tell the browser?

A <meta> viewport element gives the browser instructions on how to control the page's dimensions and scaling. The user-scalable attribute defines whether users can scale (zoom) the page content on mobile.

How do you set a viewport?

Setting The ViewportThe width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device). The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.

What is the use of viewport meta tag in HTML?

The viewport is the user's visible area of a web page. It varies with the device - it will be smaller on a mobile phone than on a computer screen. This gives the browser instructions on how to control the page's dimensions and scaling.


1 Answers

No.

When the first iPhone was released, it needed to be able to display webpages designed for viewing on computers with much larger displays. Since that was almost all websites, it defaulted to performing zoom tricks to fake having a display that size.

Meta viewport was introduced so that authors could tell the iPhone that they knew what they were doing and had actually considered mobile sized devices.

There was never a need for that on computer screen sized displays, so no support for meta viewport has ever been introduced outside of mobile browsers.

like image 162
Quentin Avatar answered Oct 15 '22 04:10

Quentin