gobbly2100 Posted July 25, 2007 Share Posted July 25, 2007 This is what I have so farHuxley NewsWhat I want to do is have the image location in the CSS document rather than in the HTML file which I htink is how I am supposed to do it.I want it to still float to the left of that text but not have the image in the HTML. Link to comment Share on other sites More sharing options...
S@m Posted July 25, 2007 Share Posted July 25, 2007 You can talk directly to that element.So lets say your div id is "mydiv"mydiv {your settings here}mydiv img {float:left;position:relative;padding...}and so on.That's how I would do it. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 25, 2007 Share Posted July 25, 2007 If you want the path to the image to be in the CSS file, you need to use it as a background image for the div, which also generally means you have to set the div to be a specific width and height. You can have the style for the div like this: .classname{ background: url(path/to/image.jpg) no-repeat top left; width: 400px; height: 300px; /* match the image dimensions */ display: inline; float: left;} <div class="classname"> </div> Link to comment Share on other sites More sharing options...
Synook Posted July 26, 2007 Share Posted July 26, 2007 Hmm... the <img /> tag is still valid XHTML, you don't have to worry about having it defined in the HTML.However, if you wanted, say, to have several different pages that have the same HTML but import different stylesheets for the content, then I suppose this approach would make sense. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.