css - What is the difference between width in % and width in px? -


if create div child of div, should set width in px or in % designing responsive website.
can please tell me 1 best?

pixels (px): pixels fixed-size units used in screen media (i.e. read on computer screen). 1 pixel equal 1 dot on computer screen (the smallest division of screen’s resolution). many web designers use pixel units in web documents in order produce pixel-perfect representation of site rendered in browser. 1 problem pixel unit not scale upward visually-impaired readers or downward fit mobile devices.

percent (%): percent unit “em” unit, save few fundamental differences. first , foremost, current font-size equal 100% (i.e. 12pt = 100%). while using percent unit, text remains scalable mobile devices , accessibility.

“ems” (em): “em” scalable unit used in web document media. em equal current font-size, instance, if font-size of document 12pt, 1em equal 12pt. ems scalable in nature, 2em equal 24pt, .5em equal 6pt, etc. ems becoming increasingly popular in web documents due scalability , mobile-device-friendly nature. value of 1 em means same thing value of 100 percent. can in opposite way: percentage value em multiplied 100.

points (pt): points traditionally used in print media (anything printed on paper, etc.). 1 point equal 1/72 of inch. points pixels, in fixed-size units , cannot scale in size.

source


a pixel great if need size match image, or if want thin border. pixels browser dependent. absolute size see on screen. may want go through : w3.org manual

also, here cool explanation css-tricks


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -