Reverting to styles defined by HTML attributes

| permalink | css

In CSS, if you want to revert back to the width and/or height attribute attached to an element, such as <img> or <table>, you can use the revert-layer keyword.

Contrary to what is shown on MDN and caniuse it is supported by all major browsers.

Styles set by HTML attributes such as width and height is called the Non-CSS Presentational Hints and lives in their own pseudo-layer between user agent and author styles, therefore the only way you can fallback to them is via revert-layer.

This works even if you don't have a layer explicitly defined.

As per W3C:

For the purpose of cascading this author presentational hint origin is treated as an independent origin, but for the purpose of the revert keyword it is considered part of the author origin.