Hi Guys,
Would someone please tell me how I actually link to css files in the <head> section of my code?
Cheers,
Mike
| SitePoint Sponsor |



Hi Guys,
Would someone please tell me how I actually link to css files in the <head> section of my code?
Cheers,
Mike



Here's the code you want:
assuming you have your style sheet in the same derectory as your HTML Page.Code:<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="/pathto/mystylesheet.css" type="text/css">
and your stylesheet is made up solely of your CSS definitions, nothing else.



Sorry guys, but neither works:S
The underline of the links still haven't gone, here is my css anyway:
The page which it is on is: http://www.gawmir.com/Templatestorm/books.htmlCode:<style type="text/css"> a.menu:link { text-decoration:none; } a:menu:visited { text-decoration:none; } a.menu:active { text-decoration:none; } a:menu:hover { text-decoration:none; } </style>
(Sorry if this is seen as advertising, but the site isn't launched yet)
Please could someone help?

Hi,
You shouldn't include the <style> and </style> tags in an external css file.
That should fix it.
Sean



Thanks mate
Also, thanks to jetboy and azizur rahman for the previous postings.
Another way to link to a CSS file that older browsers won't understand:
You can do this to hide advanced CSS (using positioning, etc.) from older browsers like Netscape 4.x.Code:<style type="text/css" media="screen"> @import url('/styles/mystyle.css'); </style>
an even more elegant solution i found to hide css from ns4.x using import: make a proper stylesheet, with all the advanced styles, and then a dummy stylesheet which only contains the @import rule. add the <link rel...> as per usual. voila'...nice and clean, using less lines of code...Originally Posted by vgarcia
re·dux (adj.): brought back; returned. used postpositively
[latin : re-, re- + dux, leader; see duke.]
WaSP Accessibility Task Force Member
splintered.co.uk | photographia.co.uk | redux.deviantart.com
I've done this too and it works pretty well. Put the basic styles in your <linked> stylesheet, and in your stylesheet use the @import rule. Nice comboOriginally Posted by redux
.
the only problem i found with this approach is: if you have the @import rule at the beginning of your basic stylesheet to import the complex styles, it needs to be at the beginning of the basic sheet. now, the modern browsers would presumably read the advanced styles first, THEN carry on reading the simple styles. if the simple styles overwrite some of the advanced styles, you may end up getting simple styles in modern browsers...if that makes senseOriginally Posted by vgarcia
the approach i've taken: have two <link rel...> links, one with the simple styles first, then one going to the dummy/advanced ones. this way modern browsers see the simple ones first, but these are then overwritten by the advanced ones...
geeez...what a convoluted way of explaining it...hope it made some sense![]()
re·dux (adj.): brought back; returned. used postpositively
[latin : re-, re- + dux, leader; see duke.]
WaSP Accessibility Task Force Member
splintered.co.uk | photographia.co.uk | redux.deviantart.com
Should that not be:Originally Posted by webmasternovis
?Code:<style type="text/css"> a.menu:link { text-decoration:none; } a.menu:visited #changed : to . { text-decoration:none; } a.menu:active { text-decoration:none; } a.menu:hover #changed : to . { text-decoration:none; } </style>
~The Artist Latterly Known as Crazy Hamster~
922ee590a26bd62eb9b33cf2877a00df
Currently delving into Django, GIT & CentOS
Bookmarks