I want to put several of these in various places on my site, floating to the right, for example, with text wrapped around them. So I need to create a class, I’m thinking.
It’s not working. I understand you use a “.” for classes and a “#” for ID’s, and I understand why I should use a class instead of an ID for this, but I’m not always sure when to use a div or not and how to do the CSS selector part properly. Can I name it whatever I want (such as floatright so I know later what it’s for) or are there only certain things I can use? I would appreciate any kind souls who can help me out.
It’s not working. I understand you use a “.” for classes and a “#” for ID’s,
Hi,
Yes that is correct about the classes and I don’t see any errors in your css.
I took your test code and used one of my own images and it is working fine for me.
Your image url does not have an extension on it, try correcting that and it should work.
In fact when I ran your code the alt text flashed up very briefly then disappeared.
When I’ve encountered a similar problem with an image (local, not remotely hosted) applying the wrapper as:
.affwrapper {
float: right;
vertical-align: text-top;
width: 300px; /* or as percentage, whatever it is*/
margin: 0 5px 0 5px; /* re: top right bottom left adjustable - as this applies, if at all*/
}
.left10 {
margin: 0 0 0 10px; /* adjustable borders, or again as you had it: margin-left: 10px; */
}
Then placing right in the image tag, or in your case the <img src
... border="0" align="right" class="left10"/>
And be sure to look at in IE7 ( especially if the text output width is less than image width, which in your case, it isn’t…just saying)
Thank you both. I tried both suggestions, and based on datadriven’s code, I simply added
align="right"
in the img src in the HTML. But if I left that part off it didn’t work. What I don’t get is why do you have to put it in there if the “affwrapper” class is already telling it to align right?
Edited: Thanks, edmondk7 as well for your suggestion.
Still no luck. I am interested in finding out why this is the case, but I have to hit the hay for the night. Even though I can now solve the problem using align=“right” in the HTML, I want to understand the concepts behind this so I can add to my slowly growing knowledge of CSS. If you have any further ideas, that would be great - but I very much appreciate your help so far!
When it aligned right, are you getting the margin?
Did you have to place something like left10 class in the img src?
Laburke: I can now solve the problem using align=“right” in the HTML
Rayzur: That’s deprecated in the strict doctype your using
That has me concerned because I’m using it the same way among pages having both:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
You really shouldn’t be building new pages with a transitional dtd and you need to keep deprecated elements out of your strict dtd which you should be using.