Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-21-2004, 12:43 PM
jordanmcclements's Avatar
WebProWorld Veteran
 

Join Date: Oct 2003
Location: Northern Ireland
Posts: 563
jordanmcclements RepRank 1
Default .css with Mozilla woes...

I decided to start learing CSS as it was becoming a real pain to try to change the layout / colour scheme ever increasing count of web pages. I started with a fairly basic css file that had the font size and background colour etc etc, and tried this on my index.html.

It seemed to work fine, so I changed all my html files to use my new 'style.css' file. I was really pleased with the way I could change the background colour etc of every web page now by just changing one file. It really did work perfectly in IE and Opera.

Then, just as I was saying to myself "this is going much more smoothly than I had anticipated', and feeling generall smug about things, I tried it on Mozilla...............

Cue about 4 hours of messing around to no avail... Eventually, I took out all the tables, and fancy font declarations etc etc in my code, until eventually I had my code pared down to the following:-


(the following is saved as 'style.css'
in the same folder as my index.html file)
---------------------------------------
<style type="text/css">
<!--
BODY {background-color: #404060;}
-->
</style>
---------------------------------------


(The following is saved as'index.html')
---------------------------------------
<html>
<head>
<title></title>
<link rel="StyleSheet" href="style.css" type="text/css">
</head>
<body>
This is a test......
</body>
</html>
---------------------------------------

And STILL it will not work for me in Mozilla (or Firefox) - both are the latest versions.

I have to admit that I am starting to get dissilusioned with the whole css thing!

NB the css file is definitely being read by mozilla because when I change the font properties in the css file, it picks these up OK....

Is there somehting really stupid that I am missing?
Reply With Quote
  #2 (permalink)  
Old 05-21-2004, 01:12 PM
WebProWorld Pro
 

Join Date: Mar 2004
Location: Pittsburgh, PA, USA
Posts: 114
ChrisRC RepRank 0
Default

You shouldn't have <style> tags in an external CSS file. This is probably what's causing your problem.

<style> is an html/xhtml tag, not CSS. You also don't need the SGML comment delimiters () in your external CSS.

Quote:
when I change the font properties in the css file, it picks these up OK
Are you sure about that? I tried it to no effect.
Reply With Quote
  #3 (permalink)  
Old 05-21-2004, 01:15 PM
WebProWorld Member
 

Join Date: May 2004
Location: UK
Posts: 83
M0rtym0use RepRank 0
Default

jordanmcclements,

in the .css file you don't need the style tag or comment code as follows...

< style type="text/css">
<!--
BODY {background-color: #404060;}
-->
< /style>

The below will do the job.
you do not need to put each declaration on a seperate line but it does make it easier to read and make future changes to..

BODY
{
background-color: #404060;
}

hope this helps

MM
__________________
M0rtyM0use

Simply Rugby
Reply With Quote
  #4 (permalink)  
Old 05-24-2004, 05:51 AM
jordanmcclements's Avatar
WebProWorld Veteran
 

Join Date: Oct 2003
Location: Northern Ireland
Posts: 563
jordanmcclements RepRank 1
Default

Thank you both very much.

I knew it had to be somehting really simple.

(I promise to do a bit more research in the future before implementing something I don't fully understand....).
Reply With Quote
  #5 (permalink)  
Old 05-24-2004, 09:21 AM
WebProWorld Pro
 

Join Date: Mar 2004
Location: Pittsburgh, PA, USA
Posts: 114
ChrisRC RepRank 0
Default

Hey, mistakes are a great learning tool. Those 4 hours banging your head against that brick wall can sure give you a headache though:)

(If you've ever seen discussions where designers complain about IE supporting 'bad code' as if it were OK, here's a good example of why.)
Reply With Quote
  #6 (permalink)  
Old 05-26-2004, 08:43 AM
jordanmcclements's Avatar
WebProWorld Veteran
 

Join Date: Oct 2003
Location: Northern Ireland
Posts: 563
jordanmcclements RepRank 1
Default

ChrisRC :-) - I agree.

In answer to your previous question: Yes, I am certain about the font changing but the background colour not changing when the above format for the external .css file was used - I have just tried this again, and this is definitely the case.

(Very strange).
Reply With Quote
  #7 (permalink)  
Old 05-26-2004, 10:41 AM
WebProWorld Member
 

Join Date: May 2004
Location: UK
Posts: 83
M0rtym0use RepRank 0
Default

jordanmcclements,
a few things you could try...

remove the last ; before the closing of brackets

also this address may be helpful to yourself.
http://www.blooberry.com/indexdot/ht...cssmapping.htm

hope this helps...
__________________
M0rtyM0use

Simply Rugby
Reply With Quote
  #8 (permalink)  
Old 05-27-2004, 10:44 AM
jordanmcclements's Avatar
WebProWorld Veteran
 

Join Date: Oct 2003
Location: Northern Ireland
Posts: 563
jordanmcclements RepRank 1
Default

Thanks,

I got it all working by removing the '<style type="text/css">
<!-- '

part of the external css file. But I was just commenting on the fact that it was bit strange that parts of the file were picked up by Mozilla and others were not (when using the incorrect format for an external css file).

Thanks again.
Reply With Quote
  #9 (permalink)  
Old 05-28-2004, 07:57 AM
WebProWorld New Member
 

Join Date: May 2004
Location: United Kingdom
Posts: 19
odujardin RepRank 0
Default

Beware! The reason why the font change works in your environment is probably because you have this font installed on your computer. Try to upload your changes and test them from computer lambda and you may not see your font at all!
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , ,



Thread Tools
Display Modes

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

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


Search Engine Optimization by vBSEO 3.2.0