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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:24:41+00:00 2026-05-26T09:24:41+00:00

With jQuery.css() I’ve been told I can use the following two functions for the

  • 0

With jQuery.css() I’ve been told I can use the following two functions for the same results:

$(".element").css("marginLeft") = "200px";

$(".element").css("margin-left") = "200px";

I’ve always used marginLeft as this is what is used in the documentation:

http://api.jquery.com/css/

Shorthand CSS properties (e.g. margin, background, border) are not
supported. For example, if you want to retrieve the rendered margin,
use: $(elem).css(‘marginTop’) and $(elem).css(‘marginRight’), and so
on.

Why has jQuery allowed for marginLeft as well as margin-left? It seems pointless and uses more resources to be converted to the CSS margin-left?

  • 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-26T09:24:42+00:00Added an answer on May 26, 2026 at 9:24 am

    jQuery’s underlying code passes these strings to the DOM, which allows you to specify the CSS property name or the DOM property name in a very similar way:

    element.style.marginLeft = "10px";
    

    is equivalent to:

    element.style["margin-left"] = "10px";
    

    Why has jQuery allowed for marginLeft as well as margin-left? It seems pointless and uses more resources to be converted to the CSS margin-left?

    jQuery’s not really doing anything special. It may alter or proxy some strings that you pass to .css(), but in reality there was no work put in from the jQuery team to allow either string to be passed. There’s no extra resources used because the DOM does the work.

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

Sidebar

Related Questions

How can I hide the scrollbar of using css/jQuery? I notice that the slideDown()
I'm trying to use jquery and blueprint css to do a (so i thought)
So I'm trying to set up this jQuery CSS dock menu and you can
I want to use jQuery to asynchronously load CSS for a document. I found
A jQuery CSS class sets the following: .newwidget { border: 1px solid #5a9ee9; background:
TL;DR: I'm using jQuery .css() to set the background color of an element, but
I'm using jQuery CSS function to style some elements $element.css(style); This works, but a
Basically Im attempting to take a php / jquery / css / html web
Im using JQuery with css to show div's on a page with the Click
I get color value with jQuery with .css('color') , and then I know color

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.