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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:51:40+00:00 2026-05-20T21:51:40+00:00

can you set the the image size of this control with css? <img style=border-width:

  • 0

can you set the the image size of this control with css?

<img style="border-width: 0px;" alt="Test image" src="userdata/1/uploadedimage/database%20entry.jpg">

Not sure if theres a way I can assign a certain size to this either by css or by Jquery? Or if I can do it directly in my C# code using something like img.Style?

EDIT:

Just to clarify my css is like so:

div .test
{
  width:90%; 
  z-index:1; 
  padding:27.5px; 
  border-top: thin solid #736F6E;
  border-bottom: thin solid #736F6E;
  color:#ffffff;
  margin:0 auto;
  white-space: pre;
  white-space: pre-wrap;
  white-space: pre-line;
  word-wrap: break-word;
}

And my code dynamically assigns images on the fly within my div when a user types something into a textbox (the div is also dynamically assigned)

while (reader.Read())
                    {
                        System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
                        div.Attributes["class"] = "test";
                //div.Style["float"] = "left";

                        div.ID = "test";
                        Image img = new Image();
                        img.ImageUrl = String.Format("{0}", reader.GetString(1));
                        // this line needs to be represented in sql syntax
                        //img.ImageUrl = "~/userdata/2/uploadedimage/batman-for-facebook.jpg";
                        img.AlternateText = "Test image";

                        div.Controls.Add(img);
                        div.Controls.Add(ParseControl(String.Format("{0}", reader.GetString(0))));
                        div.Style["clear"] = "both";
                        test1.Controls.Add(div);

So how would I use the below answers in this combination

  • 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-20T21:51:40+00:00Added an answer on May 20, 2026 at 9:51 pm

    Absolutely. <img> tags accept both height and width declarations through CSS. If you wanted to do it inline, it’d be (for height and width values of 100px):

    <img style="border-width: 0px; width:100px; height:100px;" alt="Test image" src="userdata/1/uploadedimage/database%20entry.jpg" />
    

    Better would be to use CSS targeting instead of inline:

    <style type="text/css">
        img {border-width:0px; width:100px; height:100px;}
    </style>
    

    And your img tag would then be:

    <img alt="Test image" src="userdata/1/uploadedimage/database%20entry.jpg" />
    

    That would apply to all img tags on the page (which is probably not what you want) so you can add a class (or id) to the image to further refine the CSS selection:

    <style type="text/css">
        img.mySize {border-width:0px; width:100px; height:100px;}
    </style>
    
    <img class="mySize" alt="Test image" src="userdata/1/uploadedimage/database%20entry.jpg" />
    

    Use the dot for class declarations. Use the # for id’s.

    Incidentally, if you want to maintain proportions, you can simply define the width without the height. Browsers will automatically adjust the height per the aspect ratio.

    jQuery provides access to altering many CSS properties of nodes:

    $('img').css({
        height: 100,
        width: 100
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I set a different background-image CSS attribute to my <BODY> tag depending on
I need to set maximum height and width of a image in <img> tag.
Is there a way we can set an Image instead of plain colors as
How can i set an image to a circular slider, which is an object
I'm trying to set the background image of canvas using canvas.setBackgroundImage(image); How can i
Is it possible to set transparency of any image in javascript? And how can
I can set data in JTable constructor, and then user can change this data
I have an image as the background for an input field. I can set
I want to load an image from a resource Set the image width, ensuring
You can enable featured images for posts and set their size by using the

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.