CSS Round Display Level 1

Editor’s Draft,

More details about this document
This version:
https://drafts.csswg.org/css-round-display/
Latest published version:
https://www.w3.org/TR/css-round-display-1/
Previous Versions:
Test Suite:
http://test.csswg.org/suites/css-round-display-1_dev/nightly-unstable/
Feedback:
CSSWG Issues Repository
Inline In Spec
Editors:
(LG Electronics)
(LG Electronics)
(LG Electronics)
Suggest an Edit for this Spec:
GitHub Editor

Abstract

This document describes CSS extensions to support a round display. The extensions help web authors to build a web page suitable for a round display.

CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, etc.

Status of this document

This is a public copy of the editors’ draft. It is provided for discussion only and may change at any moment. Its publication here does not imply endorsement of its contents by W3C. Don’t cite this document other than as work in progress.

Please send feedback by filing issues in GitHub (preferred), including the spec code “css-round-display” in the title, like this: “[css-round-display] …summary of comment…”. All issues and comments are archived. Alternately, feedback can be sent to the (archived) public mailing list www-style@w3.org.

This document is governed by the 2 November 2021 W3C Process Document.

1. Introduction

Conventionally, web pages have been shown through a rectangular screen such as PC, tablet, and smart phone. The window content area in a web browser is a rectangle. Each HTML element follows the W3C box model and thus is also a rectangle.
Nowadays, devices come in varied shapes of the displays. It needs to consider the shape of the display when implementing web pages on devices. However, current web standards lack some features to support the devices as follows:

  1. Lack of the capability to detect the shape of a display
  2. Lack of layout mechanisms suitable for the shape of a display
In order to facilitate the use of the web especially on a round display, there could be some features to support it.

The shape media feature is added to Media Queries. Current user agents are not capable of detecting the shape of a display so that authors cannot apply various layouts for a round display. To resolve the issue, shape informs the web page of the property regarding the shape of the display.

To apply the shape of a display to content area, we extend the shape-inside property of CSS Shapes. The position of the element which is overflowed from the display is adjusted inside the display when using this property even if the authors don’t know the exact shape of the display.

We also add the border-boundary property to CSS Backgrounds and Borders. The borders of the element can be drawn along the edge of the display even if the element is overflowed.

This module provides features such as:

1.1. Value Definitions

This specification follows the CSS property definition conventions from [CSS2] using the value definition syntax from [CSS-VALUES-3]. Value types not defined in this specification are defined in CSS Values & Units [CSS-VALUES-3]. Combination with other CSS modules may expand the definitions of these value types.

In addition to the property-specific values listed in their definitions, all properties defined in this specification also accept the CSS-wide keywords as their property value. For readability they have not been repeated explicitly.

2. Terminology

This specification follows the CSS property definition conventions from [CSS21].
The detailed description of Media Queries is defined in [MEDIAQUERIES-4]
The detailed description of CSS Shapes is defined in [CSS-SHAPES-2]
The detailed description of Backgrounds and Borders is defined in [CSS3BG]
The detailed description of Positioned Layout is defined in [CSS3-POSITIONING]

3. Detecting the shape of the display

Media Queries [MEDIAQUERIES-4] define mechanisms to support media-dependent style sheets, tailored for different environments. We propose to extend Media Queries by adding the shape media feature to support various types of displays. This will allow web authors to apply different styles to a web page on the rounded display.

3.1. The shape media feature

Name: shape
For: @media
Value: rect | round
Type: discrete

Describes the general shape of the targeted display area of the output device. It accepts the following values:

rect
The shape is an axis aligned rectangle or square, or a similar shape such as rounded rectangle for which the traditional designs are appropriate.
round
The shape is rounded or a similar shape to the circle such as an oval, an ellipse for which distinctively rounded designs are appropriate.
The following examples show what shape media feature can do when the web page is on the various shapes of displays. The sample web page is a simple clock application written in HTML and seen through the rectangular display and the rounded display.

In the first example, the clock application doesn’t implemented with shape media feature, so it can’t deal with different types of displays. It only uses 'rectangle.css' which is designed for the rectangular display no matter what the type of the display is. On the round display, some parts of the clock application would be clipped.

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="rectangle.css" />
</head>
<body>
    <div id="clockLayer">
        <div id="clockLayer">
            <div id="date">2015/02/28 (SAT)</div>
            <div id="time">10:11</div>
            <div id="weather"><img src="cloudy.png" /></div>
        </div>
    </div>
</body>
</html>
An image of a clock within a rectangle display

(A) Rectangle Display

An image of a clock within a round display

(B) Round Display

Clock Application without the shape media feature

On the other hand, in the second example, the clock application uses shape media feature. The following media queries are added to the code of the clock application from the first example.

<!-- index.html -->
<head>
    <link media="screen and (shape: rect)" rel="stylesheet" href="rectangle.css" />
    <link media="screen and (shape: round)" rel="stylesheet" href="round.css" />
</head>

If the clock application is loaded in a round display, 'round.css' which is the design for the round display will be applied by the Media Queries mechanism.

An image of a clock within a rectangle display

(A) Rectangle Display
(when 'shape: rect' returns true)

An image of a clock within a round display

(B) Round Display
(when 'shape: round' returns true)

Clock Application with the shape media feature

Note: So far, the only standard APIs of Operating System which exposes information about the display’s shape is isScreenRound() API in Android. isScreenRound() API returns a boolean that says round or not.
Referred the semantics of this API, when isScreenRound() returns true, shape: round should evaluate to true and shape: rect should evaluate to false when isScreenRound() returns false.
shape is dealing with 2 shapes, but it can be extended if there are the needs about configuring other shapes from the developers.

Note: There are cases when the UA may know the shape even in the absence of OS APIs. For example, when rendering to PDF, the shape is known to be a rectangle, so 'shape: rect' evaluates to true while shape: round to false

4. Extending the @viewport rule

4.1. The viewport-fit descriptor

viewport-fit can set the size of the visual viewport.

Name: viewport-fit
For: @viewport
Value: auto | contain | cover
Initial: auto
Percentages: N/A
Computed value: as specified

The initial layout viewport seen through the physical screen of the device. On rounded screen, the part of the page that’s currently shown on-screen is round but the viewport is rectangular. Because of this, depending on the size of the viewport, some part of the page may be clipped.

An image of the clipped area between the viewport bounding box and the device’s border
Clipped area

viewport-fit can control the clipped area by setting the size of the visual viewport.

Values have the following meanings:

auto
This value doesn’t affect the initial layout viewport, and the whole web page is viewable. What the UA paints outside of the viewport is undefined. It may be the background color of the canvas, or anything else that the UA deems appropriate.
contain
The initial layout viewport and the visual viewport are set to the largest rectangle which is inscribed in the display of the device. What the UA paints outside of the viewport is undefined. It may be the background color of the canvas, or anything else that the UA deems appropriate.

Note: With this value, 'border-boundary: display' and 'shape-inside: display' have no effect.

cover
The initial layout viewport and the visual viewport are set to the circumscribed rectangle of the physical screen of the device.

When setting the size of the bounding box for the viewport on the non-rectangular display, we have to consider the factors like below:

The author can decide which factor is more critical than another. If it have to be guaranteed that any part of the web page isn’t hidden, avoiding clipping is more important than having a gap between the bounding box of the viewport and the border of the screen. If the author doesn’t want web pages to be small for the readability, then it would be better to set viewport-fit as cover and to implement pages with considering the clipped parts.

This example shows the size of the bounding box for the viewport specified with viewport-fit on the rounded display.

When the viewport-fit is specified with contain, the initial viewport is applied to the largest inscribed rectangle of the display.

@viewport (viewport-fit: contain) {
    /* CSS for the rectangular design */
}      
An image about the viewport applied to the bounding box specified with 'viewport-fit: contain'
With 'viewport-fit: contain'

When cover is given to the viewport-fit, the initial viewport is applied to the circumscribed rectangle of the display.

@viewport {
    viewport-fit: cover;
}
@media (shape: round){
    /* styles for the round design */
}
@media (shape: rect){
    /* styles for the rectangular design */
}
An image about the viewport applied to the bounding box specified with 'viewport-fit: cover'
With 'viewport-fit: cover'

5. Aligning content along the display border

5.1. The shape-inside property

CSS Shapes [CSS-SHAPES-2] define the shape-inside property that aligns contents along the edge of a possibly non-rectangular wrapping area. Web authors may use this feature to fit contents inside a round display. However, it can be challenging to specify the wrapping area to be identical to the shape of a display. To address such cases, shape-inside is extended with a new value named 'display', such an element having this value will have its content (or contained elements) aligned along the display border automatically.

Name: shape-inside
Value: auto | outside-shape | [ <basic-shape> || shape-box ] | <image> | display
Initial: auto
Applies to: block-level elements
Inherited: no
Percentages: n/a
Computed value: computed lengths for <basic-shape>, the absolute URI for <uri>, otherwise as specified
Canonical order: per grammar
Animatable: as defined for <basic-shape>, otherwise discrete

The example below shows how the shape-inside property works when it is set to 'display'. Without using Media Queries, contents can be aligned within the display edge automatically.

<style>
    #container {
        shape-inside: display;
        // the same as circle(50% at 50%, 50%) in a regular round display
    }
    #green-box { float: left; }
    #blue-box { float: right; }
</style>
<div id="container">
    <p>
        Some inline content
        <img id="green-box" src="green-box.jpg" />
        with a float left and float right, in a
        <img id="blue-box" src="blue-box.jpg" />
        simple box with a circle shape-inside.
    </p>
</div>


A layout of web contents without shape-inside:display

(A) Without 'shape-inside'

A layout of web contents with shape-inside: display

(B) With 'shape-inside: display'

Align the content along the display border

This property is specially useful for complex shapes (e.g. curved, stelliform, polygonal), that wouldn’t be covered by <basic-shape> (i.e. circle() or ellipse()), allowing web authors to conveniently align contents with the display edge.

When a containing block is placed on one end of the display and the containing block has 'shape-inside: display', the descendant blocks of the containing block are basically put on the overlapping region between the containing block and the display area. The overlapping region’s shape is mostly complicated shape, so it’s difficult to define the shape using previous method like basic-shape. The figure 4 describes these circumstances as follows.

An image of two examples to show the principle of shape-inside: display
Align the content along the display border

What if content overflows? Clipping or scrolling?

6. Drawing borders around the display border

6.1. The border-boundary property

We add the border-boundary property to set a boundary constraint that affects the borders of an element.

Name: border-boundary
Value: none | parent | display
Initial: none
Applies to: all elements
Inherited: yes
Percentages: n/a
Computed value: specified keyword
Canonical order: per grammar
Animation type: discrete

When the border-boundary property on an element is set to 'parent', additional borders of the element could be drawn where the element’s area and the borders of its parent are met. When it is set to 'display', additional borders could be drawn where the element’s area and the borders of screen are met. The default value is 'none', imposing no boundary constraint on the borders.

The example below shows how the border-boundary property works on drawing borders. The result is shown in Figure 5B.
<style>
    #container {
        border-boundary: display;
    }
    #redBox {
        border: 5px red solid;
    }
    #greenBox {
        border: 5px green solid;
    }
    #blueBox {
        border: 5px blue solid;
    }
</style>
<div id="container">
    <div id="redBox"></div>
    <div id="greenBox"></div>
    <div id="blueBox"></div>
</div>


An image of circle drawing border lines without border-boundary: display

(A) Without 'border-boundary'

An image of circle drawing border lines with border-boundary: display

(B) With 'border-boundary: display'

Align the content along the display border

Note: If the value of border-boundary is parent or display, border lines of the element are actually just a visual effect. It triggers a layout for rendering in a general way, but in the above cases (border-boundary: parent|display), the layout doesn’t occur and it only draws the border lines inward from the containing block’s borders. With this situation, the borders might hide contents around the display edge.

7. Use Cases

Use cases are described on these.

8. Changes

8.1. Changes from March 1th 2016 version

See also previous changes.

9. Security Considerations

There are no known security issues introduced by these features.

10. Privacy Considerations

There are no known privacy issues introduced by these features.

11. Acknowledgements

This specification is made possible by input from Dong-Young Lee, Soonbo Han, Florian Rivoal, Joone Hur, Kang-Soo Seo, Sangjo Park, Woojun Jung, Chisoon Jeong, Yunbum Sung, Alan Stearns, Brad Kemper, and the CSS Working Group members. Thanks also to Adenilson Cavalcanti for editorial input.

Conformance

Document conventions

Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.

All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words “for example” or are set apart from the normative text with class="example", like this:

This is an example of an informative example.

Informative notes begin with the word “Note” and are set apart from the normative text with class="note", like this:

Note, this is an informative note.

Advisements are normative sections styled to evoke special attention and are set apart from other normative text with <strong class="advisement">, like this: UAs MUST provide an accessible alternative.

Tests

Tests relating to the content of this specification may be documented in “Tests” blocks like this one. Any such block is non-normative.


Conformance classes

Conformance to this specification is defined for three conformance classes:

style sheet
A CSS style sheet.
renderer
A UA that interprets the semantics of a style sheet and renders documents that use them.
authoring tool
A UA that writes a style sheet.

A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module.

A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)

An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.

Partial implementations

So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported component values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.

Implementations of Unstable and Proprietary Features

To avoid clashes with future stable CSS features, the CSSWG recommends following best practices for the implementation of unstable features and proprietary extensions to CSS.

Non-experimental implementations

Once a specification reaches the Candidate Recommendation stage, non-experimental implementations are possible, and implementors should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec.

To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.

Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the public-css-testsuite@w3.org mailing list.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[CSS-CONDITIONAL-3]
David Baron; Elika Etemad; Chris Lilley. CSS Conditional Rules Module Level 3. URL: https://andreubotella.com/csswg-auto-build/test/css-conditional-3/
[CSS-DEVICE-ADAPT-1]
Rune Lillesveen; Florian Rivoal; Matt Rakow. CSS Device Adaptation Module Level 1. URL: https://andreubotella.com/csswg-auto-build/test/css-device-adapt/
[CSS-IMAGES-3]
Tab Atkins Jr.; Elika Etemad; Lea Verou. CSS Images Module Level 3. URL: https://andreubotella.com/csswg-auto-build/test/css-images-3/
[CSS-VALUES-3]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 3. URL: https://andreubotella.com/csswg-auto-build/test/css-values-3/
[CSS-VALUES-4]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 4. URL: https://andreubotella.com/csswg-auto-build/test/css-values-4/
[CSS21]
Bert Bos; et al. Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification. URL: https://andreubotella.com/csswg-auto-build/test/css2/
[CSS21]
Bert Bos; et al. Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification. URL: https://andreubotella.com/csswg-auto-build/test/css2/
[MOTION-1]
Dirk Schulze; et al. Motion Path Module Level 1. URL: https://drafts.fxtf.org/motion-1/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://datatracker.ietf.org/doc/html/rfc2119

Informative References

[CSS3-POSITIONING]
Elika Etemad; Tab Atkins Jr.. CSS Positioned Layout Module Level 3. URL: https://andreubotella.com/csswg-auto-build/test/css-position-3/
[CSS3BG]
Bert Bos; Elika Etemad; Brad Kemper. CSS Backgrounds and Borders Module Level 3. URL: https://andreubotella.com/csswg-auto-build/test/css-backgrounds/
[MEDIAQUERIES-4]
Florian Rivoal; Tab Atkins Jr.. Media Queries Level 4. URL: https://andreubotella.com/csswg-auto-build/test/mediaqueries-4/
[MEDIAQUERIES-5]
Dean Jackson; et al. Media Queries Level 5. URL: https://andreubotella.com/csswg-auto-build/test/mediaqueries-5/

Property Index

Name Value Initial Applies to Inh. %ages Ani­mat­able Anim­ation type Canonical order Com­puted value
border-boundary none | parent | display none all elements yes n/a discrete per grammar specified keyword
shape-inside auto | outside-shape | [ <basic-shape> || shape-box ] | <image> | display auto block-level elements no n/a as defined for <basic-shape>, otherwise discrete per grammar computed lengths for <basic-shape>, the absolute URI for <uri>, otherwise as specified

@media Descriptors

Name Value Initial Type
shape rect | round discrete

@viewport Descriptors

Name Value Initial Computed value Percentages
viewport-fit auto | contain | cover auto as specified N/A

Issues Index

What if content overflows? Clipping or scrolling?