Skip to content

Some styles are implemented as UA rules instead of presentational hints #13111

Open

Description

@Loirooriol

What is the issue with the HTML Standard?

https://html.spec.whatwg.org/multipage/rendering.html has lots of styles which are "expected to apply, as presentational hints".

For example, from https://html.spec.whatwg.org/multipage/rendering.html#tables-2

table[border] > tr > td, table[border] > tr > th,
table[border] > thead > tr > td, table[border] > thead > tr > th,
table[border] > tbody > tr > td, table[border] > tbody > tr > th,
table[border] > tfoot > tr > td, table[border] > tfoot > tr > th {
  /* only if border is not equivalent to zero */
  border-width: 1px;
  border-style: inset;
}

No browser implements this as a presentational hint, they do it using the UA origin. The difference is observable:

<!DOCTYPE html>
<table border="50">
  <tr>
    <td style="border-style: revert"></td>
  </tr>
</table>

You can still see border-style: inset in Firefox, Chrome and Safari, because it's in the UA origin. If it was a presentational hint, it would have been reverted, according to https://drafts.csswg.org/css-cascade-5/#preshint

This other example is an actual presentational hint: https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3

pre[wrap] { white-space: pre-wrap; }

as observed in this testcase, which outputs pre, because white-space: pre-wrap gets reverted since it's an actual presentational hint.

<!DOCTYPE html>
<pre id="target" wrap style="white-space: revert"></pre>
<script>
document.write(getComputedStyle(target).whiteSpace);
</script>

I think all the styles need to be reviewed one by one, check what browsers do, and update the spec accordingly

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions