user1187968
user1187968

Reputation: 7986

Limit maximum image width on web broswer

What is the best practice to limit the maximum image width on the browser, with only HTML and CSS? I did a search on Google.com, and I didn’t find any good results. Thanks!

Also, I want to keep the proportion height ratio as well.

Upvotes: 1

Views: 1742

Answers (2)

Eugene Retunsky
Eugene Retunsky

Reputation: 13139

Use style="max-width:NNNpx" (or max-height:NNNpx) (you can use % as a measurement as well - e.g. max-width:10%)

Upvotes: 4

Ryan
Ryan

Reputation: 1395

You can limit the width of images using CSS:

img.limit-width {
    max-width:50%;
}

You can use px and em in addition to a percentage as well.

Upvotes: 1

Related Questions