How come we can have color value first in box-shadow rule?

36 Views Asked by At

The documentation for box-shadow clearly states that the first option is for length value, and color value comes last.

How come than that the below works?

box-shadow: #0000002e 0px 1px 2px;

.style {
  height: 50px;
  width: 100%;
  box-shadow: #0000002e 0px 1px 2px;
}
<div class="style"></div>

1

There are 1 best solutions below

0
Barry Michael Doyle On BEST ANSWER

The order is optional, you can put the color at the beginning or the end and it wouldn't be "incorrect".

In the documentation it states <shadow> = inset? && <length>{2,4} && <color>

Those && separators mean that they're mandatory, but order is not important. The ? for inset? and <color>? mean that those fields are optional.

The compiler sets the values based off the input type.