<style>
img{
max-height:250px;
max-width:250px;
height:auto;
width:auto;
}</style>
I don’t want all images on the page to have these proportions that contain the image tag. How would I alter this code so as to assign it to only specific image tags.
Thanks
I might be missing something here, but surely you can just add a class to those images you want these styles to apply to, and target the styles to the class.
Errmm, use more “specific ” selectors?
eg. instead of img {
something like img.logo {
Nothing personal, but this is very basic beginner level CSS and I think you could benefit from giving this at least a quick read.
If after reading it you don’t understand something of that, please ask.
1 Like
No offense taken, thank you for your response.
I had already tried:
<style>
img.resize{
max-height:250px;
max-width:250px;
height:auto;
width:auto;
}</style>
and then
<img.resize border="0" src="image.jpg">
and it didn’t work. No image wrote to the page.
Did I do something wrong?
You need to add the class to the HTML as <img class="resize"...>
.
As @Mittineague says, this is very basic stuff, so do take time to familiarise yourself with classes and IDs.
(And take the “border” declaration out of the HTML. It belongs in CSS.)
1 Like
Thank you for that, it works. I appreciate your help and advice.
2 Likes
Thank you for the advice and I am changing and adding a lot of css styles to my pages. Thanks again!
1 Like
system
Closed
June 3, 2018, 3:14pm
8
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.