Is it considered bad practice to use vw on the height property and vice versa?

I used 20vw on a height property and it worked out better.

Should I only use vh for the height property and vw for the width property?

Vw on height of an element? I assume you know that by making window/continer wider you will make that element taller? Width will not change.

By looking at your posts I see that you really wnat to get that sizing thing “right”. But it often depends on a lot of things, so there is hardly a “one right choice for every situation”.

Use search engines to look into best practices of programming topics and read what experts say.
Here is the one of those articles.

Also, remember that best will change over a period of time.
Like 3 - 5 years from now there will be another best way to size <div> element.

Just do what feels right to you and if someone will come and will say “this is better” - think if this is true and make changes (or not).

For now, just try to learn many different things, their advantages and disadvantages. Then you will be able to choose “best” (if there is any).

You’ve already gotten a good answer, but generally I’d say that using vw to set the height of an element is absolutely not “bad practice”, however it would make sense only in very few cases.

If you say “it works better”, does it still work better if you resize the window and make it really narrow or wide?

BTW, it might sound strange, but using vw for widths is usually a bad idea. Use % instead.

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