Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6118503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:26:39+00:00 2026-05-23T15:26:39+00:00

I have a WebView that is formatted via a CSS file – I dynamically

  • 0

I have a WebView that is formatted via a CSS file – I dynamically generate the HTML from within the app for this view, much like a web server does. The generated HTML references a static CSS file for formatting. I have an image formatting instruction such as:

img {
    width: 20px;
    height: 20px;
}

To make this device independent I’d like to use dip rather that px for the width and height measurements. I cannot figure out (nor find) how to specify dip as a unit in a css definition. I have tried “dp” and “dip”, neither of which worked. Can this be done?

I know that I can have multiple versions of the CSS file that are selected via a <“target-densitydpi=high-dpi”> type of selector but this means that I will have duplicate CSS files just for the ability to size images according to different device densities. Doable, but I’d prefer to be able to specify dip in the CSS file and have the WebView do the work for me.

Also doable would be to generate the inline style sheet in the HTML head and convert dip to px for the specific device but this then leads to a coupling between the CSS definition and the HTML generation code. Probably better than multiple CSS files (for my application), but it would be far nicer to just set dip in the CSS file and be done with it.

(My images are designed to allow resizing without artifacts for the range of screen densities that are currently supported)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:26:40+00:00Added an answer on May 23, 2026 at 3:26 pm

    What units are available in CSS are here:

    http://www.w3.org/TR/css3-values/#lengths

    There is no dp or dip, so I am not sure how you have gotten an idea such a unit such exist.

    Instead, CSS spec says pixel sizes should be scaled to device relative sizes.

    This is theory.

    The practice is that you probably want to generate CSS dynamically to support such feature.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WebView that loads a local HTML file like this: [webView loadRequest:[NSURLRequest
I have a Cocoa app that uses a WebView to display an HTML interface.
I have a webview that has some custom HTML loaded into it. In this
I have a WebView that is fed from a background thread via a ServerSocket
I have various pieces of generated HTML/JS that I load into Activity with WebView#loadDataWithBaseURL.
I have a WebView that is loading a page from the Internet. I want
I want to have a webview that has a single HTML and a single
In my app, I have to display a specific webpage in a WebView that
This is an obscure, possibly hardware dependent error. I have a webview that is
I have a webview that I am navigating within. I have implemented go back

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.