Is there a difference between initial-scale=1 and initial-scale=1.0?

Viewed 462

I have seen code that is written like this: <meta name="viewport" content="width=device-width, initial-scale=1">, but I have also seen code that is written like this: <meta name="viewport" content="width=device-width, initial-scale=1.0"> Is there a difference between initial-scale=1 and initial-scale=1.0?

2 Answers

No. The specification describes the viewport <meta> tag content parsing algorithm non-normatively, but says the following about values:

If a prefix of property-value can be converted to a number using strtod, the value will be that number. The remainder of the string is ignored.

strtod is a function from the C standard library. strtod("1") is equal to strtod("1.0"), which is equal to the number 1, so there's no difference.

initial-scale sets the initial zoom factor of the page to the defined value, calculated relative to the ideal viewport. Thus it generates a visual viewport width. It also sets the layout viewport width to the visual viewport width it just calculated.

As far as I know, there's no difference between initial-scale=1 and initial-scale=1.0.

But I suggest you to use initial-scale=1.0 to keep the same typewriting with all other possible values (range between 0.1 and 10.0).

Related