Jump to content

Placing Image


gobbly2100

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...