• Help
  • Search
  • Login
  • Register
  • Home

Forum: web design and graphics community

Celestial Star Forum > Web Development > Coding > Code for having an alternative stylesheet?
Pages: [1]
« previous next »
  Print  
Author Topic: Code for having an alternative stylesheet?  (Read 1146 times)
blahdee-
Guest
Code for having an alternative stylesheet?
« on: July 03, 2008, 09:44:53 PM »

I don't know if you guys know what I'm talking about, but here goes!
I want to know how you can have two stylesheets on the same page (just incase the visitor has a different browser)

because all I would have on a site would be:
<link rel="stylesheet" href="style.css" type="text/css">

and a friend told me that I had to have something like this: [if IE] in my header to make it work?? @__@; sorry if this is confusing!
Logged
katie-kate
Incubus
**
Posts: 58



View Profile WWW
Re: Code for having an alternative stylesheet?
« Reply #1 on: July 03, 2008, 11:03:26 PM »

I know exactly what you're talking about, because my friend used to do it all the time in my webdesign class. Unfortunately I don't know how to do it myself, but I'm sure you could find some tutorials online...I do know that it's called "browser sniffing," which might help you find more information. Good luck!
Logged

Moorina
Angeling
*
Posts: 5


moo


View Profile WWW
Re: Code for having an alternative stylesheet?
« Reply #2 on: July 04, 2008, 04:24:40 AM »

I'm pretty sure you're talking about browser specific CSS (or browser sniffing). You need to add a conditional comment syntax to the <head> of your page.

Code:
<!--[if IE]>
  <link rel="stylesheet" type="text/css" href="ie.css" />
<![endif]-->

here is a good page to target more specific versions of IE.
Logged
blahdee-
Guest
Re: Code for having an alternative stylesheet?
« Reply #3 on: July 04, 2008, 11:41:03 AM »

Thank you!! It works! =DD but does it only work for IE?

--This was the layout that was giving me problems xD
http://kissandtell.reiku.org/layouts/01/
« Last Edit: July 04, 2008, 12:06:19 PM by blahdee- » Logged
Moorina
Angeling
*
Posts: 5


moo


View Profile WWW
Re: Code for having an alternative stylesheet?
« Reply #4 on: July 06, 2008, 10:00:59 PM »

Not too sure if there are others. There may be one for Opera, but I think it uses Javascript.
Logged
Vangs
Administrator
Valkyrie Randgris
*****
Posts: 516



View Profile WWW
Re: Code for having an alternative stylesheet?
« Reply #5 on: July 07, 2008, 06:16:53 AM »

In HTML there is only conditional comments for IE. The reason being is that all other browsers ignore these comments, they're treated like regular comments. If you want to target different browsers you'll need to look at a different browser sniffing method such as Javascript or PHP.

Personally I use PHP in my projects to deliver a stylesheet relevant to the users browser, however this becomes redundant if the user saves the page then views it in another browser -- though I personally rationalize this as the user's own problem if they save the page. Smiley
Logged

Pages: [1]
  Print  
« previous next »
 
Jump to:  

  • Welcome, Guest
  • Members login
  • Register for free

General

  • General
  • New members
  • Announcements
  • Support / Suggestions

Art boards

  • Creative mediums
  • Requests and offers
  • Tutorials
  • Celestial Star tutorials

Web development

  • Coding
  • Web design
  • Advertisements / affiliation

Off-topic

  • The non-sense
  • Ertentainment

Go up
eXTReMe Tracker
  • Valid XHTML
  • Valid CSS
Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC | Seo4Smf v0.2 © Webmaster's Talks
Loading...