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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:58:00+00:00 2026-05-16T03:58:00+00:00

I was wondering if in the width and height <img> attributes, I could specify

  • 0

I was wondering if in the width and height <img> attributes, I could specify width and height as percentages?

Well, I guess that is obvious, because when I try so, it resizes, but it appears to skew the quality of my image.

Here is an example of my markup with fixed attributes:

<img src="#" width="346" height="413">

Now, while trying to scale this down, say by half, via percentages:

<img src="#" width="50%" height="50%">

I get something completely different than:

<img src="#" width="173" height="206.5">

I think I’m just fundamentally mistaking my percentage markup or something because there is a noticeable difference between my second and third example visually.

  • 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-16T03:58:01+00:00Added an answer on May 16, 2026 at 3:58 am

    Note: it is invalid to provide percentages directly as <img> width or height attribute unless you’re using HTML 4.01 (see current spec, obsolete spec and this answer for more details). That being said, browsers will often tolerate such behaviour to support backwards-compatibility.

    Those percentage widths in your 2nd example are actually applying to the container your <img> is in, and not the image’s actual size. Say you have the following markup:

    <div style="width: 1000px; height: 600px;">
        <img src="#" width="50%" height="50%">
    </div>
    

    Your resulting image will be 500px wide and 300px tall.

    jQuery Resize

    If you’re trying to reduce an image to 50% of its width, you can do it with a snippet of jQuery:

    $( "img" ).each( function() {
        var $img = $( this );
        $img.width( $img.width() * .5 );
    });
    

    Just make sure you take off any height/width = 50% attributes first.

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

Sidebar

Related Questions

I was wondering if it's possible to verify a DIV's width and height on
I'm playing with RavenDb and wondering if I'm missing something obvious. Thing is, that
I've learnt from somewhere a long time ago that specifying width and height for
Just wondering if someone could help me with a very simple SQL query. I
I have a filled Shape, and a BitmapData that is the same width and
I am wondering if it is possible to keep an img inside a div
I was wondering if anyone could help me troubleshoot some CSS issues I'm running
I need to get the original width and height of an image given a
I'm wondering how to handle sub processes with the back button in mind. For
I was wondering how you can handle files with variables in the url like

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.