Jump to content

Help With External Stylesheet


phprocker

Recommended Posts

Hey all.  I have some CSS styling in my page headers that works only when included on the page itself and not linked from a file.  Can anyone see what I'm doing wrong?

 

index.php

<head>
<link rel="stylesheet" type="text/css" href="styles/default.css" />
</head>

//code that doesn't load the external style
<table class="background1" width="1000px" height="420px" cellspacing="10" cellpadding="15"></table>

 

styles/default.css

.background1 {background-image:url(images/meh.gif);}

.background2 {background-image:url(images/back.png);}

img {border-style:none;}

Link to comment
https://forums.phpfreaks.com/topic/217158-help-with-external-stylesheet/
Share on other sites

Rather than relative links, you should try to put absolute links in code to ensure all the files are found. This generally can be achieved by simply putting a slash before your directory structure. I would do this for both the html file calling the CSS and in the CSS file calling for images - like so:

 

<head>
<link rel="stylesheet" type="text/css" href="/styles/default.css" />
</head>

//code that doesn't load the external style
<table class="background1" width="1000px" height="420px" cellspacing="10" cellpadding="15"></table>

.background1 {background-image:url(/images/meh.gif);}
.background2 {background-image:url(/images/back.png);}
img {border-style:none;}

 

Also, why are you putting style information in your <table> tag instead of the stylesheet?

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.