Features in CSS 3 and beyond define simple yet powerful features to create graphical effects, such as rounded corners, shadow effects, and rotated content.
Animations can be described declaratively via CSS Animations and CSS Transitions.
Scripted animations can be resource intensive, especially on constrained devices. The possibility offered by the Animation Frames to manage the rate of updates to animations can help to keep them under control.
By default, the box model in CSS specifies that any padding and border of an element are to be laid out and drawn outside of the specified width and height for the element. The effective external size of a box thus varies with the padding and border used, which complicates the design of responsive layouts where developers want to vary box sizes based on the size of the screen. The
border-box value of the
box-sizing property tells the user agent to lay out and draw padding and border inside the specified width and height for the element, which usually simplifies the design of responsive layouts.
CSS Flexbox and CSS Grid introduce two new layout modes, designed for laying out more complex applications. Notably, they make it possible to preserve a clear separation between the content itself (HTML, SVG) and its layout by allowing re-ordering of elements on screen, without having to change the underlying HTML. This is particularly relevant on mobile devices where the user interface and user experience need to be adjusted to fit the screen and available interaction mechanisms (see also Device Adaptation).
Flexbox focuses on space distribution within an axis, and uses a simpler bottom-up approach to layout, while Grid enforces 2-dimensional alignment, and uses a top-down approach to layout. It is expected that both will be valuable and complementary tools for web developers.
Ruby annotations are short runs of text presented alongside base text, primarily used in East Asian typography as a guide for pronunciation or to include other annotations. The HTML ruby element allows text to be marked with ruby annotations. The ruby-align, ruby-position, and other properties defined in CSS Ruby provide a way to control the rendering of the HTML ruby element.
Fonts play also an important role in building appealing graphical interfaces, but mobile devices are in general distributed with only a limited set of fonts. WOFF (Web Open Font Format) addresses that limitation by making it easy to use fonts that are automatically downloaded through style sheets, while keeping the size of the downloaded fonts limited to what is actually needed to render the interface. WOFF is particularly friendly to mobile devices, thanks to a font data preprocessing and optimization step that reduces redundancy of font data structures, and a dedicated entropy coding scheme for compression that does not require excessive CPU or memory usage for decoding, even on lower-end mobile devices.
2D Vector Graphics
SVG, Scalable Vector Graphics, provides an XML-based markup language to describe two-dimensions vector graphics. Since these graphics are described as a set of geometric shapes, they can be zoomed at the user request, which makes them well-suited to create graphics on mobile devices where screen space is limited. They can also be easily animated, enabling the creation of very advanced and slick user interfaces.
The integration of SVG in HTML5 opens up new possibilities, for instance applying advanced graphic filters (through SVG filters) to multimedia content, including videos. SVG 2 is set to facilitate that integration and complete the set of features in SVG.
In complement to the declarative approach provided by SVG, the
<canvas> element added in HTML5 enables a 2D programmatic API that is well-suited for processing graphics in a less memory intensive way.
Similarly, WebGL, developed outside of W3C as part of the Khronos Group, provides a low-level 3D graphics API for the Web. This API has been built to be compatible with OpenGL ES, i.e. for embedded systems, and is intended to work on mobile devices. In practice, WebGL v1.0, based on OpenGL ES 2.0, is well supported across devices. Support for WebGL v2.0, based on OpenGL ES 3.0, is less pervasive. Work on a newer WebGPU API is ongoing, see the Technologies in progress section below.
Another important aspect in graphics-intensive applications (e.g. games) is the possibility to use the entire screen to display the said graphics; the work on a Fullscreen API to request and detect full screen display, now done in the WHATWG.
Technologies in progress
Animations can also be managed via scripting through the API exposed in Web Animations.
CSS Painting API allows web developers to generate a 2D image for CSS that can respond to style and size changes, without having to create DOM elements and without blocking the main thread during repaint, thus preserving memory, CPU, and responsiveness.
The WebGPU API exposes modern 3D graphics and computation capabilities in a performant, powerful and safe manner, with a goal to be agnostic of and compatible with existing native system platforms (such as Direct3D, Metal, or Vulkan). The companion WebGPU Shading Language specification defines a text-based shading language for WebGPU based on SPIR-V semantics.
Given the time required for downloading fonts over mobile networks, authors need to adapt their content to the progressive availability of fonts. CSS Font Loading gives the necessary events and interfaces to developers to enable that adaptation. The
font-display descriptor for
@font-feature-values rules can also be used to control how a downloadable font renders before it is fully loaded.
Font variations along different axes (width, weight, optical size) can be encoded in a single font file. The font variation properties in CSS allow finer control over usage of font variants and can further help developers avoid unnecessary network requests to fetch additional variants of a font.
Content rarely fits on screen on mobile devices, requiring users to scroll down. Applications may want to adjust their user interface based on the current scroll position, for example to shrink the top navigation menu as the user starts scrolling or to display a progress bar. This requires scripting for now. The Scroll-linked Animations specification proposes a declarative mechanism based on CSS properties.
|Feature||Specification / Group||Implementation intents|
CSS Working Group