linking to a stylesheet in xhtml

  • the_Maven
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Feb 02, 2004
  • Posts: 196
  • Status: Offline

Post February 2nd, 2004, 5:07 pm

Hey,
I'm trying to convert my site to xhtml and I have everything working fine ... except for the stylesheet. I'm rather confused. Help?

Here are the first three lines of code (in case it has something to do with it:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

Neither of these work:

<link href="site.css" media="screen" type="text/css" />

<?xml-stylesheet href="site.css type="text/css" />

- The Maven
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post February 2nd, 2004, 5:07 pm

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post February 2nd, 2004, 5:15 pm

Chances are your style sheet code is something similar to this:

Code: [ Select ]
<link rel="stylesheet" type="text/css" href="resume.css">


That's normal for HTML 4.01, but you need to add a forward slash at the end for XHTML like this:

Code: [ Select ]
<link rel="stylesheet" type="text/css" href="stylesheet.css" />


If that doesn't work, make sure that the link is correct and the stylesheet is where it is supposed to be. Also, notice how all the elements are small case for XHTML. With HTML 4.01 it doesn't matter, but with XHTML all elements and attributes need to be small case.

---------looks like you edited your post--------
OK then try this:
Code: [ Select ]
<link rel="stylesheet" type="text/css" href="site.css" />


It should work.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post February 2nd, 2004, 5:35 pm

Just noticed in your code...you have this:

Code: [ Select ]
<?xml-stylesheet href="site.css type="text/css" />


I've never tried it that way, so would have no idea if it would work anyway, but you are missing a closing quotation mark after site.css. XHTML is very particular about closing quotation marks.

Also, technically your doctype declaration should be:

Code: [ Select ]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2.   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


I also think if you are going to include XML in the document, you need to include this prior to the doctype:

Code: [ Select ]
<?xml version="1.0" encoding="iso-8859-1" ?>
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • the_Maven
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Feb 02, 2004
  • Posts: 196
  • Status: Offline

Post February 2nd, 2004, 6:08 pm

Thanks, I'll have to try that. :D
- The Maven
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Joined: Dec 29, 2003
  • Posts: 5169
  • Loc: SC-USA
  • Status: Offline

Post February 2nd, 2004, 7:15 pm

If you're writing for older browsers you can also do this:
Code: [ Select ]
<link rel="stylesheet" type="text/css" href="style for old browsers.css" />
<style>@import url("style for new browsers.css");</style>
  1. <link rel="stylesheet" type="text/css" href="style for old browsers.css" />
  2. <style>@import url("style for new browsers.css");</style>

older browsers, like NS 4.x, will only read the LINK tag. Newer browsers, however, will read both tags and give preference to the document referenced in the @import declaration.
- dM
  • the_Maven
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Feb 02, 2004
  • Posts: 196
  • Status: Offline

Post February 2nd, 2004, 7:58 pm

Thanks digitalMedia,

the @import url method worked for me. I really appreciate that.

- The Maven
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post February 2nd, 2004, 8:12 pm

Yep...nice tip dM. I love it when a family comes together!
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 101 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.