What's dp (density independent pixels) units with CSS?

how to pronounce what
what does
whats app
what w
what is love

For Android, people recommend using dp (density independent pixels) measurements for UI elements, and there are conventions that exist such as using 48dp for a button height, etc.

I'm working on a web application, and I'm getting a lot of criticism on the UI design saying it does not conform with Android design standards. Obviously, my application is going to look different since it is using CSS and HTML instead of the Android Holo theme, but I would still like to make it conform as much as possible. However CSS does not allow density independent measurements.

When I test my application on different resolutions and pixel densities, it does not look good, and sometimes, it is way out of proportion so it's not even functional. CSS doesn't have dp units like Android native development does, but I was wondering what some alternatives are.

Can I somehow get the pixel density using Javascript and manually scale everything appropriately? What is the best way for making a web app that looks and works nicely on all resolutions/densities?

What, I will do what I can to help you. TranslationsEdit. show ▽what? (interrogative pronoun)� WhatsApp works with Safari 9+ To use WhatsApp, update Safari or use Google Chrome, Mozilla Firefox or Opera.. Update Safari

I disagree with the currently accepted answer. As uber5001 suggests, a px is a fixed unit, and in a similar spirit to the efforts of the Android-specifc dp.

Per Material's spec:

When writing CSS, use px wherever dp or sp is stated. Dp only needs to be used in developing for Android.


When designing for the web, replace dp with px (for pixel).

what, what definition: 1. used to ask for information about people or things: 2. used in questions that show you are…. Learn more. noun the true nature or identity of something, or the sum of its characteristics: a lecture on the whats and hows of crop rotation.

In CSS3 it may be more accurate to say that the web doesn't have Android's px. The spec for CSS3's px says this:

pixels; 1px is equal to 1/96th of 1in

px might be the measurement you want, in the future.

WHAT, It is plural if a plural noun or noun phrase completes the sentence, as in He sometimes makes what seem to be gestures of reconciliation. � Clauses with what as� what definition: 1. used to ask for information about people or things: 2. used in questions that show you are…. Learn more.

Use rem.

It is the font size of the root element and a very good base unit for the size of other UI elements.

If one used the same absolute size (in centimeter), the text and other elements would be much too big on mobile or much too small on desktop.

If one used the same amount of pixels, the text and other elements would be much too small on mobile or much too big on desktop.

The rem unit is on spot because it says "Hey, this is how big normal text should be." Basing the size of other UI elements on this is a pretty reasonable choice.

What, 'America, What a Country.' Michael Dell on His Life and Business. The billionaire tech executive discusses capitalism, immigration, innovation� whatever: adverb at all , of any description , of any kind or sort , whatsoever , whichever

As of CSS3, there are no CSS units that are truly device-independent. See the W3C spec on absolute lengths. In particular, the absolute units might not match their physical measurements.

If physical units were true to their purpose, you could use something like points; points are close enough to dps:

1 in = 72 pt
1 in = 160 dp

1 dp = 72 / 160 pt

If you use SCSS, you can write a function to return in pts:

@function dp($_dp) {
  @return (72 / 160) * $_dp + pt;

And use it:

.shadow-2 {
  height: dp(2);

'America, What a Country.' Michael Dell on His Life and Business , Hong Kong had brought local transmission way, way down. But numbers are now going up. What kind of restrictions are being introduced for� The ORIGINAL and OFFICIAL "What What (In the Butt)" video! Samwell will CALL your friends and family! Go here: http://officialsamwell.com/live-call/ This is

Coronavirus FAQ: Cases Are Spiking Again In Hong Kong. What Are , What the 15 biggest US school districts are planning for reopening. By Theresa Waldrop, CNN. Updated 1:33 PM ET, Fri July 31, 2020. Dr. Gupta demonstrates� WhatsApp Messenger: More than 2 billion people in over 180 countries use WhatsApp to stay in touch with friends and family, anytime and anywhere. WhatsApp is free and offers simple, secure, reliable messaging and calling, available on phones all over the world.

What the top 15 school districts are doing to reopen, Quickly send and receive WhatsApp messages right from your computer. Seen a font in use and want to know what it is? Upload an image to WhatTheFont to find the closest matches in our database.

WhatsApp Web, Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.

  • CSS's px is the same as dp on Android. According to the CSS3 spec. on units and values.
  • Are those units displayed properly when deploying in iOS ?
  • @jmhostalet No, it causes the browser to go into a sort of infinite loop since the viewport height is dynamic.
  • this answer is incorrect, because the px unit in css is (counter-intuitively) actually already pixel density independent -- "a css pixel is a not a pixel", there are plenty of articles about this
  • This is answer. +1 for quoting the Material spec.
  • From MDN: "The unit in doesn't represent a physical inch on screen, but represents 96px. That means that whatever is the real screen pixel density, it is assumed to be 96dpi. On devices with a greater pixel density, 1in will be smaller than 1 physical inch. Similarly mm, cm, and pt are not absolute length." developer.mozilla.org/en/docs/Web/CSS/…
  • CSS inch and physical inch are 2 different things. 1 CSS inch is always 96px, regardless of screen density. So only on a 96 dpi monitor could CSS inch and physical inch be considered equal.
  • @MaciejKrawczyk I understand the base of your contention about the disparity in scale on px. I could argue on about how a px is indeed a fixed unit, and the scale you involve doesn't change this base truth, but that's a red herring. The reality is the Material spec directly states to use px wherever dp is suggested. Given Brad asked about Android design standards, I provided the canonical, and thus correct, answer.
  • The recent update (May 2018) to material design explains Pixel Density in more depth material.io/design/layout/#pixel-density
  • I can't see how this transition will happen without breaking everything. And using the same absolute size (in cm) for, say, text on mobile and desktop is not a good paradigm.
  • And 1in is defined as 96px . CSS units like in, mm are pixel density dependent.
  • yo siempre use px en vez de dp y va bien
  • Mind blown :OOOO
  • You do not need to set the font size. The default font size of the root element is usually a pretty reasonable choice for the device at hand.