PX to EM Conversion


<!--
main_leaderboard, all: [728,90][970,90][320,50][468,60]-->
PX to EM Conversion
❮ Previous
Next ❯
PX to EM Converter
- Set a default font size (usually 16px)
- Then, convert a pixel value to em, based on the default size
- Or, convert an em value to pixels, based on the default size
Set a default font size:
px
Convert PX to EM:
px
Convert EM to PX:
em
Result:
<!--
mid_content, all: [300,250][336,280][728,90][970,250][970,90][320,50][468,60]-->
Body Font Size
In the table below, select a body font size in pixels (px) to display a
complete "px to em and percent" conversion table.
Tip: The default font size is usually 16px.
What is the difference between PX, EM and Percent?
Pixel
is a static measurement, while percent and EM are relative
measurements. The size of an EM or percent depends on its parent. If the text
size of body is 16 pixels, then 150% or 1.5 EM will be 24 pixels (1.5 * 16).
Look at CSS Units for more
measurement units.
function fillTable(x)
var t = "";
t = t + "
px" t = t + " | em" t = t + " | percent" t = t + "" for (i = 5; i < 26; i++) t = t + " |
---|---|---|
" + i + "px" t = t + " | " + (i/x).toFixed(4) + "em" t = t + " | " + ((i/x) * 100).toFixed(2) + "%" t = t + "" t = t + ""; document.getElementById("demo").innerHTML = t; fillTable(16); function wrong() document.getElementById("myInput2").disabled = true; document.getElementById("myInput2").value = ""; function wrong2() document.getElementById("myInput").disabled = true; document.getElementById("myInput").value = ""; function works() document.getElementById("myInput2").disabled = false; document.getElementById("myInput2").value = ""; function works2() document.getElementById("myInput").disabled = false; document.getElementById("myInput").value = ""; function myFunction() ❮ Previous Next ❯ |