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

  • SEARCH
  • Home
  • 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 89875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:47:07+00:00 2026-05-10T22:47:07+00:00

As in the subject, how can one get the total width of an element,

  • 0

As in the subject, how can one get the total width of an element, including its border and padding, using jQuery? I’ve got the jQuery dimensions plugin, and running .width() on my 760px-wide, 10px padding DIV returns 760.

Perhaps I’m doing something wrong, but if my element manifests itself as 780 pixels wide and Firebug tells me that there’s 10px padding on it, but calling .width() only gives 760, I’d be hard pressed to see how.

Thanks for any suggestions.

  • 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. 2026-05-10T22:47:07+00:00Added an answer on May 10, 2026 at 10:47 pm

    [Update]

    The original answer was written prior to jQuery 1.3, and the functions that existed at the time where not adequate by themselves to calculate the whole width.

    Now, as J-P correctly states, jQuery has the functions outerWidth and outerHeight which include the border and padding by default, and also the margin if the first argument of the function is true


    [Original answer]

    The width method no longer requires the dimensions plugin, because it has been added to the jQuery Core

    What you need to do is get the padding, margin and border width-values of that particular div and add them to the result of the width method

    Something like this:

    var theDiv = $('#theDiv'); var totalWidth = theDiv.width(); totalWidth += parseInt(theDiv.css('padding-left'), 10) + parseInt(theDiv.css('padding-right'), 10); //Total Padding Width totalWidth += parseInt(theDiv.css('margin-left'), 10) + parseInt(theDiv.css('margin-right'), 10); //Total Margin Width totalWidth += parseInt(theDiv.css('borderLeftWidth'), 10) + parseInt(theDiv.css('borderRightWidth'), 10); //Total Border Width 

    Split into multiple lines to make it more readable

    That way you will always get the correct computed value, even if you change the padding or margin values from the css

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

Sidebar

Related Questions

I know that it's a subject that can raise a lot of debate, but
As from subject. How can I determine if the applet is running in the
The subject says it all. Trying to see if I can't change that loading
In my application user can share information with different apps using: shareIntent.putExtra(Intent.EXTRA_SUBJECT, Link from
It appears so, but I can't find any definitive documentation on the subject. What
I've read the article (and few others on the subject), but still can't figure
I have a problem using DatagramSocket. The problem is that I can't run two
I use jquery ajax method, set datatype json, I get a jsonp response from
there seem to be a few posts on this subject but i can't find
There was a previous question on StackOverflow about this subject (can insert the link,

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.