If no value is given to width, height, what does the browser do?

If no value is given to width, height, what does the browser do?

Example:

width: 30px;

width:30;

width="12" height="14"

width=“12px” height=“14px”

In SVG, values can be set with or without a unit identifier.

Does that mean in CSS also?

Hi @asasass I believe if no unit is specified the value will be incorrect and nothing will be applied by default.[quote=“asasass, post:2, topic:280855”]
Does that mean in CSS also?
[/quote]
No I don’t think so

2 Likes

You’re right. Thank you.

You would normally only set width and height attributes like width="12" height="14" on images and similar content, and it is understood that these values always refer to pixels.

When you set width and height values using CSS, you can choose from a wide range of units, including, px, em, rem, %, etc. Because of this, you must specify which you are using, for the browser to know how to render it. 50px is very different from 50em or 50%.

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.