What is better to use in CSS, percent or pixels?

I'm not a CSS expert, and I want to create a design that looks good in all browsers and resolutions. I noticed that some websites create their own design ( width , height , margin , padding ) with percentage, not pixels, and I do my whole design with percentage too. Does this approach have any problems?

Please advise me.

+6
source share
3 answers

You will not have problems using this approach, and the percentage and pixels will work depending on your needs. If you need a liquid site, then a percentage may be your best option. And ems for fonts, so the user can change its display if necessary.

A few expert opinions on this issue:

http://kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs

http://webdesign.about.com/cs/typemeasurements/a/aa042803a.htm

And here's an interesting twist: Percentage + pixels:

http://www.cssplay.co.uk/boxes/outside.html

+9
source

I think you should look at this:

http://kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/

It depends on your needs, I prefer to use em instead of pixels or percent. I also noticed that IE isn’t eating too much interest, but ems works fine.

+2
source

To have the scale of the site depending on the resolution or size of the browser window, percentages would be the best choice. The only problem you may encounter is the difficulty of reading the content if the resolution is very low or the browser window size is small, in which case the content may be overloaded and make it difficult to read. the use of percentages, not pixels, will make the site liquid and will be adjusted in accordance with the resolution and scale of the window.

0
source

Source: https://habr.com/ru/post/900500/


All Articles