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 8552219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:22:37+00:00 2026-06-11T14:22:37+00:00

I am using an Android WebView to display my app’s HTML content. I need

  • 0

I am using an Android WebView to display my app’s HTML content. I need to dynamically find the full height of an element (usually a div) including padding, margin, and border. I am using JavaScript, and cannot use jQuery.

I have been using scrollHeight on my div to get the height. I got the computed style of the div using var style = window.getComputedStyle(DIV, null); and got the top and bottom margin by calling style.marginTop and style.marginBottom. They were both 0px. The problem is that scrollHeight still does not account for the height of the margins belonging to div’s.

I got the child elements of my div (usually a P or H* tag) and obtained the same fields the same way: scrollHeight, marginTop, and marginBottom. The scrollHeights are the exact same (as I usually only have one child per div), but there is usually a top or bottom margin value in the child that is not reflected in the parent element.

I don’t really understand why this is so. It appears as through the child’s margin is rendered outside of parent, but the parent has no knowledge of it, and cannot directly access it.

I am looking for a way to access the margin defined by the child through the parent element. Is that possible?

This Question was very helpful, but I did not find an underlying reason for why it is rendered this way and the thread seems to have grown cold.

Thanks!

  • 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-06-11T14:22:38+00:00Added an answer on June 11, 2026 at 2:22 pm

    Sime Vidas pointed me in the right direction, so thanks!

    I found myself trying to find out the exact height of the collapsed margins between divs and their children (but worded it much differently in my question). When accessing that information trough the DOM it will tell me style attributes of the parents and children, but it does not report the height of any collapsed margins.

    So…the real answer to my question is NO. I have not been able to find a way to directly access the attribute of the collapsed margins.

    What is just as good is taking the offsetTop attribute of my div, and finding the difference between the offsetTop attribute of the next Div. That gives the total height including final rendering of margins. To find the margins only, subtract the scrollHeight.

    This may not work in all scenarios, but was more than enough for my purposes.

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

Sidebar

Related Questions

I have an Android app using webview to load and display html pages. But
I am writing an Android app that uses a WebView to display content. The
I am using webview in my android app to fetch some webpages from multiple
In my android app, I am playing a youtube video using WebView with IFrame
I am using webview in android to display images (mainly using google ajax API),
I'm using Android, and I've created a Webview which nicely opens my HTML page
I am working on an Android app which displays content in a WebView. The
I am developing an android application and I need to display HTML page. I
I am building an android app which has a webview. The webview will display
I am supposed to display html data in an Android Webview. I am able

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.