function

Type() — CSS reference

A type() argument to attr() specifies a CSS syntax for parsing an attribute. If parsing fails, the supplied fallback is used. It is not a general JavaScript type check; use it within a grammar that accepts it.

Formal Syntax & Structure

css syntaxcss
width: attr(data-width type(<length>), 20px);

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>type()</title><style>body{margin:0;background:white}#a{box-sizing:border-box}#a,#b{width:20px;width:attr(data-width type(<length>),20px)}</style><body><div id="a" data-width="80px">A</div><div id="b" data-width="oops">B</div></body></html>
CSS Reference