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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:18:31+00:00 2026-05-23T19:18:31+00:00

This is probably too basic but I’m unable to figure out how this is

  • 0

This is probably too basic but I’m unable to figure out how this is done.

To modify one CSS property of a div, I do this:

$('#myDiv').css('width', '300');

What if I want to modify both width and height?

This —

$('#myDiv').css('width', '300', 'height', '250');

— didn’t work.

Chaining it works:

$('#myDiv').css('width', '300').css('height', '250');

— but I’m wondering if there’s more elegant, simpler syntax for it. Would be grateful for someone’s advice.

  • 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-23T19:18:32+00:00Added an answer on May 23, 2026 at 7:18 pm

    Try this

    $('#myDiv').css({width: '300', height: '250'});

    From official documentation

    jQuery can equally interpret the CSS and DOM formatting of multiple-word properties. For example, jQuery understands and returns the correct value for both .css({‘background-color’: ‘#ffe’, ‘border-left’: ‘5px solid #ccc’}) and .css({backgroundColor: ‘#ffe’, borderLeft: ‘5px solid #ccc’}). Notice that with the DOM notation, quotation marks around the property names are optional, but with CSS notation they’re required due to the hyphen in the name.

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

Sidebar

Related Questions

This is probably a basic CSS question, but I am not fluent in CSS
this is probably too simple of a question, but here I go. I have
I hope this question is not considered too basic for this forum, but we'll
Probably this is a basic stuff, but better learn now then later. What i'm
UPDATE** This is probably too much code. But... heres the situation. I have a
This is probably way too vague for any concrete answers, but this issue has
This probably has a simple answer, but I must not have had enough coffee
This probably sounds really stupid but I have noo idea how to implement jquery's
This probably sounds like a terrible idea at first glance, but here is my
I know this probably really simple but Im not sure what im doing wrong...

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.