Date First Published: 26th February 2023
Topic: Web Design & Development
Subtopic: Web Technologies
Article Type: Computer Terms & Definitions
Difficulty: MediumDifficulty Level: 5/10
Learn more about what the viewport is in this article.
The viewport is the visible area of a webpage on a smartphone, tablet, laptop, desktop computer, or other devices. The size is determined by the size of the user's device and the application used to access the webpage. For example, on smartphones, the viewport is the whole screen size of the screen and on desktop computers, the size is equal to the window size of the browser.
There are two types of viewports, which include:
A more specific definition is the viewport meta element that was introduced in HTML5, which is used to automatically adjust the webpage to the screen size of the device, making sites optimised for smaller devices, such as smartphones. The viewport has now become an important thing to consider in responsive design as devices have all sorts of different screen sizes. Ideally, this meta element should be included on all webpages. An example of the meta element can be seen below:
The properties of the viewport meta element include:
When using this meta element, webpages on mobile devices are not displayed in the same way as they would appear on a desktop screen. Without this meta element, users on mobile devices would have to zoom in or scroll horizontally to see the page since the page is too large for the viewport, creating a bad user experience.
CSS can be used to adjust the style of different elements according to the viewport size. This can be accomplished using media queries and is essential for creating elements that adapt to the user's screen size and do not malfunction on smaller devices. The @media CSS rule is used to do this and any styling under this rule will only apply to screens that fit certain dimensions. An example of the @media CSS rule can be seen below. It will hide a specified element when the screen size is below 500px.
If so, it is important that you tell me as soon as possible on this page.
Network Services Network Setups Network Standards Network Hardware Network Identifiers Network Software Internet Protocols Internet Organisations Data Transmission Technologies Web Development Web Design Web Advertising Web Applications Web Organisations Web Technologies Web Services SEO Threats To Systems, Data & Information Security Mechanisms & Technologies Computer Hardware Computer Software Ethics & Sustainability Legislation & User Data Protection