I'm trying to use material design concept for web app. In Google docs they have mentioned some spacing rules in dp.
Measurements in the above image are in dp and sp. (Check here) scroll down in that docs till specs section for field and label spacing measurements. To follow these measurements I cant figure out how to calculate px value from dp. The dp formula as mentioned in google docs is
dp = (width in pixels * 160) / screen density
To use this formula I need Screen density. So Here is the question.
How do you calculate screen density from your web application?
From the Material Design Guildelines:
When writing CSS, use px wherever dp or sp is stated. Dp only needs to be used in developing for Android.
That means: You don't need to find out the screen density (which won't be easy to do anyway).