Forum Moderators: not2easy

Message Too Old, No Replies

Post an image through CSS

         

sethhoova

9:19 pm on Mar 1, 2011 (gmt 0)

10+ Year Member



I would like to know if there is a way I can link an image OTHER THAN A background image through an external style sheet. I would like to be able to link the image in my external CSS that way in my HTML I can just type the div id="#*$!" and let the CSS do the rest instead of having to code my header for every single page.

It is a very large site that I'm working on and I basically just want a faster way to put the same header image on every page of the site.

Thanks for any suggestions.

SuzyUK

9:51 am on Mar 2, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi sethhoova, Welcome!

it is possible.. by making the image the background image of the div, or you could even make the header a background image to your body element if it's just cosmetic, and then pad the body to make the content clear it, that would save even the the typing of e.g. <div id="header"></div>

however if it's non-cosmetic, e.g. a logo with a link, you are going to lose the value of the alt text or whatever.. you will basically have an empty div, nothing for the SE's to read.. is that what you want?

maybe you're looking for something other than CSS - e.g. have you looked at SSI (Server side includes) or tried PHP includes, these would allow to include blocks of code into each page where you need to.. often used for common includes like headers, footers, even menus sitewide

if it's definitely CSS you want and are not sure how to go about it give us a shout back!

sethhoova

11:13 pm on Mar 9, 2011 (gmt 0)

10+ Year Member



Ok so I've been reading countless tuts about SSI's. So I guess my next question is can you put SSI's in your linked external CSS so that way every page you have that already in place linked CSS file, that SSI goes with it?

SuzyUK

10:40 pm on Mar 11, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi, your SSI's would build your total HTML page,

your CSS applies to to the whole generated HTML Page you built via those SSI's.. you don't put your SSI's in the CSS, but you might call you CSS - <link rel="styesheet" href="yourstyles.css"> - via the header SSI; the call to the CSS become part of the entire HTML page, then whatever is in that CSS applies style to the whole HTML page