Problems with external style sheets

This is a discussion on "Problems with external style sheets" within the Web Page Design section. This forum, and the thread "Problems with external style sheets are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 6th, 2007, 14:47
Up'n'Coming Member
Join Date: Mar 2007
Location: West Sussex UK
Age: 76
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Problems with external style sheets

Hi,

A little help please?

I have got to page 40 in the Missing Manual and am stuck on the tutorial when trying to learn external stye sheets. I am alright up to and after i have pasted the code from the internal to the external sheet but having typed :-
Code: Select all
body {
background-image: url(images/bg.jpg);
background-repeat: repeat-x;
When I view the page in the web browser the following code is visible instead of being hidden which it is when not viewing it in the broser, any idea what I am doing wrong, apart from trying to learn CSS???
Code: Select all
 body { background-image: url(images/bg.jpg); background-repeat: repeat-x; 
 h1 { color:red; font-size:2em; font-family: Arial, sans-serif; margin: 0; border-bottom:2px dashed black; } 
 p { color:#036; font-size:.9em; line-height:150%; margin-top:0; }
All of the code thus far looks like this:-

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Basic Web Page</title>
<link href="global.css" rel="stylesheet" type="text/css" />
</head>}
body {
 background-image: url(images/bg.jpg);
 background-repeat: repeat-x;
h1 {
 color:red;
 font-size:2em;
 font-family: Arial, sans-serif;
 margin: 0;
 border-bottom:2px dashed black;
}
p {
 color:#036;
 font-size:.9em;
 line-height:150%;
 margin-top:0;
<body>
Look forward to hearing from you.....

Last edited by karinne; May 7th, 2007 at 13:47. Reason: Please use [code]...[/code] tags when displaying code!
Reply With Quote

  #2 (permalink)  
Old May 6th, 2007, 16:17
New Member
Join Date: May 2007
Location: Lincoln (UK)
Age: 39
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Lcha

Howdy - Please note - im no expert here!! But for external sheets you need to set out the information roughtly as follows, the html should be....

Code: Select all
<html>
<head>
<link rel="stylesheet" type="text/css" href="mysheet.css" />  <!--This is where you need to point to your external sheet (mysheet.css shoule be renamed to what your external sheet is named)-->
</head>

<body>
<p><!-- Your website text here --></p>
</body>

</html>
Then for the external sheet put in the desired content and save as filename.css
eg from what you provided (beware - it is untested!, except for a minor adjustment)

Code: Select all
body {
background-image: url(images/bg.jpg);
background-repeat: repeat-x;}

h1 {
color:red;
font-size:2em;
font-family: Arial, sans-serif;
margin: 0;
border-bottom:2px dashed black;}

p {
color:#036;
font-size: 0.9em;
line-height:150%;
margin-top:0;}
I did notice that in your example there was missing brackets in the css which will cause a problem (make sure you close them all !) explorer might recognise the missing bracket and work around it but other browsers are not as forgiving, and your page may simply just not show in them. Also you had css in the main html file, as you are working with external I would keep it all in the external file. I hope this info helps you in your quest!
Reply With Quote
  #3 (permalink)  
Old May 7th, 2007, 13:50
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems with external style sheets

Please write a more meaningful topic next time!


As for the problem at hand, saracen has it right.

You need to put

Code: Select all
<link rel="stylesheet" type="text/css" href="stylesheet.css" media="screen" />
in the <head> ... </head> of your document.


Integrating CSS in your website
Reply With Quote
  #4 (permalink)  
Old May 8th, 2007, 15:30
moojoo's Avatar
Moderator
Join Date: Aug 2005
Location: Texas
Age: 31
Posts: 1,763
Blog Entries: 1
Thanks: 0
Thanked 18 Times in 18 Posts
Send a message via AIM to moojoo Send a message via MSN to moojoo Send a message via Yahoo to moojoo
Re: Problems with external style sheets

Or if you are placing the CSS in your HTML you need to put it in <style type="text/css"></style> tags in your head section.
__________________
The internet is just a fad.
http://www.mevans76.com
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Reply With Quote
  #5 (permalink)  
Old May 11th, 2007, 04:30
Reputable Member
Join Date: Dec 2005
Location: Texas
Age: 19
Posts: 328
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to daygon Send a message via MSN to daygon Send a message via Yahoo to daygon
Re: Problems with external style sheets

wow i didnt thik the position of the href mattered. you learn something new everyday.
Reply With Quote
  #6 (permalink)  
Old May 11th, 2007, 12:06
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems with external style sheets

Quote:
Originally Posted by daygon View Post
wow i didnt thik the position of the href mattered. you learn something new everyday.
It doesn't ...
Reply With Quote
  #7 (permalink)  
Old May 14th, 2007, 21:50
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Problems with external style sheets

I use the same order as Karinne. I get all mixed up when I see something like this, lol.

Code: Select all
<link media="screen" title="Style Sheet" href="style.css" type="text/css" rel="stylesheet" id="main" />
Reply With Quote
  #8 (permalink)  
Old May 16th, 2007, 19:18
Reputable Member
Join Date: Dec 2005
Location: Texas
Age: 19
Posts: 328
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to daygon Send a message via MSN to daygon Send a message via Yahoo to daygon
Re: Problems with external style sheets

hehe lol. yeah its better to keep stuff organized. thats hw things flow easier
Reply With Quote
Reply

Tags
hidden code

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Style sheets Oak Web Page Design 4 Mar 3rd, 2008 16:49
switching between style sheets cwjones Web Page Design 4 Jul 4th, 2007 17:06
CSS Style Sheets ronb Starting Out 3 May 10th, 2007 13:02
***Help Needed accessing external Style Sheets*** shawn2000 Flash & Multimedia Forum 1 Nov 15th, 2006 22:32
change style sheets screamer2k Web Page Design 5 Aug 6th, 2004 11:19


All times are GMT. The time now is 00:31.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43