+ 2

How is using "em" better dan "px"?? What is exactly "em"?

6th May 2017, 3:08 PM
rohan_m
rohan_m - avatar
12 Antworten
+ 5
em is a relative size unit and px is an absolute unit. When you set the font size using px it often stops the user from changing the size of the font using their browser. This means it should look the same on all browsers but is bad if the person viewing your webpage has sight difficulties as they may not be able to read it. Using em allows the user to set the size of the font so em=1 is the default size of font and for most people is the same as px=16 but if you change the default in your browser because you need it to be zoomed the text will be bigger. This is usually better as then everybody can read it.
6th May 2017, 3:26 PM
Shane
+ 20
@rohan It's not my fault BTW. You should have written units in your question... Typo ;)
6th May 2017, 3:22 PM
Dev
Dev - avatar
+ 18
Ok fine, gotcha!
6th May 2017, 3:17 PM
Dev
Dev - avatar
+ 9
@dayve actually rohan is not talking about <em>tag but he is talking measurement units
6th May 2017, 3:17 PM
Vaibhav Sharma
Vaibhav Sharma - avatar
+ 8
Actually while using em to provide dimensions, elements gets resized with the window resizing afaik. You can go through below link for better understanding: http://kyleschaeffer.com/development/css-font-size-em-vs-px-vs-pt-vs/
6th May 2017, 3:18 PM
Ashwani Kumar
Ashwani Kumar - avatar
+ 7
@rohan i also want to know please someone answer
6th May 2017, 3:18 PM
Vaibhav Sharma
Vaibhav Sharma - avatar
+ 4
em is better for everybody so use that (unless you have a really good reason that you need a font in exactly the same size on every bodies screen...like a message in a game that has to always fit in a specific sized box)
6th May 2017, 3:30 PM
Shane
+ 1
Use em or % whenever you can.
6th May 2017, 3:36 PM
Calviղ
Calviղ - avatar
0
thank u for ur answer sir..but i asked bout d em unit...not the tag
6th May 2017, 3:15 PM
rohan_m
rohan_m - avatar
0
@Dayve yup sory..i forgot about d tag..so i didnt mentioned "unit"..
6th May 2017, 3:25 PM
rohan_m
rohan_m - avatar
0
so what sud i use?? em or px?
6th May 2017, 3:26 PM
rohan_m
rohan_m - avatar
0
@shane thanks
6th May 2017, 3:31 PM
rohan_m
rohan_m - avatar