CSS Media Queries defines a mechanism that allows adapting the layout and behavior of a Web page based on some of the characteristics of the device, most notably based on the screen resolution.
The viewport-relative CSS units
vmax represent a percentage of the current viewport dimensions and let developers design layouts that automatically adapt to viewport dimensions changes.
The Responsive Images Community Group (RICG) developed an extension to HTML, known as the
picture element, that allows authors define what image to load depending on device capabilities and/or other media features.
As a complementary approach, the
srcset attribute, specified by the WHATWG and also published as an extension to HTML, let Web developers define the various device pixel ratios of an image, letting the browser pick the best choice for the pixel density of the screen.
SVG, which lets define images that can be scaled up and down without any loss of quality, is another critical tool to the development of Web applications that adapt to the resolution of the underlying device.
|CSS-based adaptation||Media Queries|
|viewport-percentage lengths in CSS Values and Units Module Level 3|
|Responsive images||picture element in HTML 5.1|
|srcset attribute in HTML 5.1|
|Scalable Vector Graphics (SVG) 1.1 Specification|
Technologies in progress
CSS Device Adaptation defines a set of CSS directives to define the size on which this layout should be based, relatively to the size of the underlying device — specifying what has been implemented using the
<meta name="viewport"> element so far.
Media Queries Level 4 adds the availability and type of a pointing device, as well as the ability to hover over elements, to the list of capabilities that may be used to adapt the layout and behavior of a Web page. Moreover, Media Queries Level 5 lets developers specify media queries that react to the ambient luminosity and to script-defined variables, making it easier to cater for more complex adaptation rules in the overall logic of the application.
A common approach to content adaptation on mobile devices is to have the server deliver the content that fits the user's device right away. This approach avoids sending content to the client that the client does not need, preserving network bandwidth, and it avoids running the adaptation logic on the client itself, preserving CPU and memory. Server-side adaptation used to rely on sniffing the
User-Agent string and mapping it to a database of devices to extract relevant capabilities. This mechanism is error-prone and requires continuous maintenance of the database of devices. Through the HTTP Client Hints mechanism, developed by the IETF HTTP Working Group, clients and servers may now opt-in to exchange relevant capabilities for efficient content adaptation. The Web Performance Working Group has started to work on a Device Memory specification that extends these hints to surface the memory available on the device. The specification also defines an API to surface that information to the Web application running on the client.
The Media Capture and Streams API exposes some specific information on capabilities of camera and microphones to make it possible to take advantage of the large variety of media capturing devices provided on mobile phones.
|CSS-based adaptation||CSS Device Adaptation Module Level 1|
|Media Queries Level 4|
|Media Queries Level 5|
|Server-side adaptation||Device Memory 1|
|Media Capture Capabilities||Source capabilities in Media Capture and Streams|
CSS Mobile Text Size Adjustment lets text adapt to zoomed parts of a page.
Most mobile devices feature on-screen keyboards for user input. They also commonly let the user pinch-zoom into a page. Both of these features preserve the layout viewport (what the web page uses when laying out its user interface), so as not to clutter the screen with
position: fixed elements. The Visual Viewport API provides developers with a way to query and interact with the properties of the visual viewport (the box on the page that the user can currently see), and to be notified when these properties change.