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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:44:45+00:00 2026-06-17T05:44:45+00:00

I have placed a span inside of the paragraph tag, now the position top

  • 0

I have placed a span inside of the paragraph tag, now the position top should show as 0 and the offset should show some other value (need to calculate from document), but i am getting the same value in both…

i am wrong?

this is my code:

HTML:

<div></div>
<p>paragraph<span>span</span>paragraph</p>

Jquery:

$('span').click(function(){
console.log($(this).position().top,$(this).offset().top)
})

CSS:

p{
  color:green;
}

span{
  color:red;
}

div{
  height:100px;
  border:2px solid blue;
}

jsfiddle here

  • 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-17T05:44:46+00:00Added an answer on June 17, 2026 at 5:44 am

    from the docs

    The .position() method allows us to retrieve the current position of an element relative to the offset parent.

    Contrast this with .offset(), which retrieves the current position relative to the document.

    When positioning a new element near another one and within the same containing DOM element, .position() is the more useful.

    If we talk about your scenario then :

    Currrently both .position() and .offset() have same parent and they will get the offset position of the document.

    Now if you add one more attribute in the css class of <p> position:relative; you can find the difference then.

    In short:

    .offset().top will get the top from the document.

    .position().top will get the top from the relative parent.(if parent is relatively set)

    you can find the difference here: http://jsfiddle.net/BhsrS/1/

    checkout the fiddle: http://jsfiddle.net/BhsrS/1/

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

Sidebar

Related Questions

I have multiple Node applications (build on Express framework). Now I have placed them
I have an absolutely placed div with an embedded YouTube video inside of it.
I have the following HTML: <ul class='dropSelect'> <li data-value=one> <span>Menu1</span> </li> <li data-value=two> <span>Menu2</span>
If I have: <span>Some Code Here</span> , can I create a new div element
I have a span tag which has got rounded circle with the height 30
I have the following html inside a <div> : <span class=footer-icons> <a href=#; class=facebook
I have placed an Image as a button in my App and I want
I have placed an image on the master page. I see the image at
I have a horizontal list on which I have placed borders on the li
In Delphi 2010, I have placed 2 radio groups onto a form then added

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.