Media queries is a feature of CSS 3 allowing content rendering to adapt to different conditions such as screen resolution (e.g. mobile and desktop screen size). It became a W3C recommended standard in June 2012, [1] and is a cornerstone technology of responsive web design (RWD).
Media queries were first sketched in Håkon Wium Lie's initial CSS proposal in 1994, [2] but they did not become part of CSS 1. The HTML4 Recommendation from 1997 shows an example of how media queries could be added in the future. [3] In 2000, W3C started work on media queries and also on another scheme for supporting various devices: CC/PP. The two address the same problem, but CC/PP is server-centric, while media queries are browser-centric. [4] The first public working draft for media queries was published in 2001, [5] and the specification became a W3C Recommendation in 2012 after browsers added support.
A media query consists of a media type and one or more expressions, involving media features, which resolve to either true or false. The result of the query is true if the media type specified in the media query matches the type of device the document is being displayed on and all expressions in the media query are true. When a media query is true, the corresponding style sheet or style rules are applied, following the normal cascading rules. [6] [7] Media queries use the @media
CSS "at-rule".
The following are examples of CSS media queries:
@mediascreenand(display-mode:fullscreen){/* Code in here only applies to screens in fullscreen */}
@mediaalland(orientation:landscape){/* Code in here only applies in landscape orientation */}
@mediascreenand(min-device-width:500px){/* Code in here only applies to screens equal or greater than 500 pixels wide */}
A media type can be declared in the head of an HTML document using the "media" attribute inside of a <link>
element. The value of the "media" attribute specifies on what device the linked document will be displayed. [8] Media types can also be declared within XML processing instructions, the @import
at-rule, and the @media
at-rule. CSS 2 defines the following as media types: [9]
The media type "all" can also be used to indicate that a style sheet applies to all media types. [10]
The following table contains the media features listed in the latest W3C recommendation for media queries, dated 6 June 2007. [11]
Feature | Value | Min/Max | Description |
---|---|---|---|
color | integer | Yes | Number of bits per color component |
color-index | integer | Yes | Number of entries in the color lookup table |
device-aspect-ratio | integer/integer | Yes | Aspect ratio |
device-height | length | Yes | Height of the output device |
device-width | length | Yes | Width of the output device |
grid | integer | No | True for a grid-based device |
height | length | Yes | Height of the rendering surface |
monochrome | integer | Yes | Number of bits per pixel in a monochrome frame buffer |
orientation | "portrait" or "landscape" | No | Orientation of the screen |
resolution | resolution ("dpi", "dpcm" or "dppx") | Yes | Resolution |
scan | "progressive" or "interlaced" | No | Scanning process of "tv" media types |
width | length | Yes | Width of the rendering surface |
The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It is often assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScript.
A HTML editor is a program for editing HTML, the markup of a web page. Although the HTML markup in a web page can be controlled with any text editor, specialized HTML editors can offer convenience and added functionality. For example, many HTML editors handle not only HTML, but also related technologies such as CSS, XML and JavaScript or ECMAScript. In some cases they also manage communication with remote web servers via FTP and WebDAV, and version control systems such as Subversion or Git. Many word processing, graphic design and page layout programs that are not dedicated to web design, such as Microsoft Word or Quark XPress, also have the ability to function as HTML editors.
Håkon Wium Lie is a Norwegian web pioneer, a standards activist, and the Chief Technology Officer of Opera Software from 1998 until the browser was sold to new owners in 2016. He is best known for developing Cascading Style Sheets (CSS) while working with Tim Berners-Lee and Robert Cailliau at CERN in 1994.
Tantek Çelik is a Turkish-American computer scientist, currently the Web standards lead at Mozilla Corporation. Çelik was previously the chief technologist at Technorati. He worked on microformats and is one of the principal editors of several Cascading Style Sheets (CSS) specifications. He is author of HTML5 Now: A Step-by-Step Video Tutorial for Getting Started Today (ISBN 978-0-321-71991-1).
JavaScript Style Sheets (JSSS) was a stylesheet language technology proposed by Netscape Communications in 1996 to provide facilities for defining the presentation of webpages. It was an alternative to the Cascading Style Sheets (CSS) technology.
Acid2 is a webpage that test web browsers' functionality in displaying aspects of HTML markup, CSS 2.1 styling, PNG images, and data URIs. The test page was released on 13 April 2005 by the Web Standards Project. The Acid2 test page will be displayed correctly in any application that follows the World Wide Web Consortium and Internet Engineering Task Force specifications for these technologies. These specifications are known as web standards because they describe how technologies used on the web are expected to function.
Tableless web design is a web design method that avoids the use of HTML tables for page layout control purposes. Instead of HTML tables, style sheet languages such as Cascading Style Sheets (CSS) are used to arrange elements and text on a web page.
A flash of unstyled content is an instance where a web page appears briefly with the browser's default styles prior to loading an external CSS stylesheet, due to the web browser engine rendering the page before all information is retrieved. The page corrects itself as soon as the style rules are loaded and applied; however, the shift may be distracting. Related problems include flash of invisible text and flash of faux text.
The Acid3 test is a web test page from the Web Standards Project that checks a web browser's compliance with elements of various web standards, particularly the Document Object Model (DOM) and JavaScript.
Web typography is the use of fonts on the World Wide Web. When HTML was first created, font faces and styles were controlled exclusively by the settings of each web browser. There was no mechanism for individual Web pages to control font display until Netscape introduced the font
element in 1995, which was then standardized in the HTML 3.2 specification. However, the font specified by the font
element had to be installed on the user's computer or a fallback font, such as a browser's default sans-serif or monospace font, would be used. The first Cascading Style Sheets specification was published in 1996 and provided the same capabilities.
Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML or XML. CSS is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript.
The Arena browser was one of the first web browsers for Unix. Originally begun by Dave Raggett in 1993, development continued at CERN and the World Wide Web Consortium (W3C) and subsequently by Yggdrasil Computing. Arena was used in testing the implementations for HTML version 3.0, Cascading Style Sheets (CSS), Portable Network Graphics (PNG), and libwww. Arena was widely used and popular at the beginning of the World Wide Web.
In web development, the CSS box model refers to how HTML elements are modeled in browser engines and how the dimensions of those HTML elements are derived from CSS properties. It is a fundamental concept for the composition of HTML webpages. The guidelines of the box model are described by web standards World Wide Web Consortium (W3C) specifically the CSS Working Group. For much of the late-1990s and early 2000s there had been non-standard compliant implementations of the box model in mainstream browsers. With the advent of CSS2 in 1998, which introduced the box-sizing
property, the problem had mostly been resolved.
Argo was part of a project to make the Internet accessible to scholars in the Humanities at the University of Groningen. The Argo web browser was created in August 1994 by Bert Bos.
The holy grail is a web page layout which has multiple equal-height columns that are defined with style sheets. It is commonly desired and implemented, but for many years, the various ways in which it could be implemented with available technologies all had drawbacks. Because of this, finding an optimal implementation was likened to searching for the elusive Holy Grail.
Responsive web design (RWD) or responsive design is an approach to web design that aims to make web pages render well on a variety of devices and window or screen sizes from minimum to maximum display size to ensure usability and satisfaction.
The CSS Working Group is a working group created by the World Wide Web Consortium (W3C) in 1997, to tackle issues that had not been addressed with CSS level 1. As of December 2022, the CSSWG had 147 members.
CSS Flexible Box Layout, commonly known as Flexbox, is a CSS 3 web layout model. It is in the W3C's candidate recommendation (CR) stage. The flex layout allows responsive elements within a container to be automatically arranged depending on viewport size.
Front-end web development is the development of the graphical user interface of a website, through the use of HTML, CSS, and JavaScript, so that users can view and interact with that website.
Prince is a computer program that converts XML and HTML documents into PDF files by applying Cascading Style Sheets (CSS). Prince is a commercial product, which is free to download and use for non-commercial purposes.