[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

Style sheet issue

Take a look at the following snippet of my .css file.

<STYLE TYPE="text/javascript">
with (tags.body) {
  marginTop="-10pt";
  marginLeft="-10pt";
  marginRight="-10pt";
  }
</STYLE>

<STYLE TYPE="text/css">
body {margin:0pt;
      //margin-top:0px;
      background-color:white;
      background-repeat:repeat-n;
      }
</style>

See the line //margin-top:0px;  If I uncomment it, or even remove it, the margin goes back to 10 in NN.  As long as I leave it as is, everything is fine.  Any ideas why the // tells the NN browser to ignore this line?  Whereas we know IE will ignore the <STYLE TYPE="text/javascript"> entries.  My thinking is that as long as NN is goint to procees the javascript code first, it will ignore the other entries.  It doesn't explain the //margin... line though.  Does NN ignore or discard anystyle properties tagged with //?  Try it with a simple image or table.  If you need the entire code let me know, it's nothing fancy, just plain html stuff
0
mgfranz
Asked:
mgfranz
  • 4
  • 4
  • 2
1 Solution
 
clockwatcherCommented:
Netscape appears to discard the entire style sheet if it's got invalid syntax which throwing the // in there does.

For example, you'll get the same results if you do something like this:


<STYLE TYPE="text/javascript">
with (tags.body) {
  marginTop="-10pt";
  marginLeft="-10pt";
  marginRight="-10pt";
  }
</STYLE>

<STYLE TYPE="text/css">
body {margin:0pt;
margin-top:0px;
background-color:green;
background-repeat:repeat-n;
this line is not supposed to be here
}
</style>

<html>
<body>
Hello
</body>
</html>
0
 
mgfranzAuthor Commented:
Hmmm... thats a though, although in IE the results are correct whether I have the // on a line or the "this line is not suppose to be here" input.  So I can suppose that in IE all styles tags are processed except a non-style, and in NN if a non-style is found, discard all the properties of that object.
0
 
clockwatcherCommented:
I think I'd just say it's a different parsing philosophy.  IE seems to ignore what it doesn't understand and Netscape seems to throw out what it doesn't understand.  IE has always been more forgiving of syntax than Netscape.

Netscape doesn't just ignore the style, if it's got a javascript entry first.  If you've got a syntactically valid statement, Netscape has no problem working with both.

E.g.,

<STYLE TYPE="text/javascript">
with (tags.body) {
  marginTop="-10pt";
  marginLeft="-10pt";
  marginRight="-10pt";
  }
</STYLE>

<STYLE TYPE="text/css">

body {
background-color:green;
}

</style>

<html>
<body>
Hello
</body>
</html>
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
clockwatcherCommented:
If you really want to account for the style sheet differences, use the javascript section after the normal style sheet.  IE will ignore it; Netscape will replace the attribute's set in the first definition with those defined in the second.

<STYLE TYPE="text/css">
body {margin:0pt;
margin-top:0px;
background-color:white;
background-repeat:repeat-n;
}
</style>

<STYLE TYPE="text/javascript">
with (tags.body) {
  marginTop="-10pt";
  marginLeft="-10pt";
  marginRight="-10pt";
  }
</STYLE>

<html>
<body>
Hello
</body>
</html>
0
 
JaguwarCommented:
Actually, // is a commented line and will be ignored in both browsers.

More importantly, there are noticeable differences between IE and Netscape in the space they leave all around the edge of your screen.  Here's a much simpler solution:

Get rid of all the CSS that refers to placement, (I'm assuming you're attempting to use the entire window space, right up to the edge, right?) and edit your body tag like this:

<body topmargin=0 leftmargin=0 marginehigt=0 marginwidth=0>

This will work in both browsers.  

HTH!

Jaguwar
0
 
mgfranzAuthor Commented:
Wrong Jag, please try your suggestions before you post an answer.  I know being new to the EE group is an honor to you, but please.  It is proper etiquite to post a comment unless you are absolutely sure your answer will solve the problem.  The // is not a comment tag in a style sheet, in JavaScript yes, but there are no comments allowed in style sheets, other than the standard <!-- -->

Besides, with your solution, all you would need is the <body style='margin:0'> tag.
0
 
JaguwarCommented:
Oops on the //, my bad.  I've been reading too many questions I think. :-)

Haven't tried what you suggested, glad to learn something even as I make a booboo! :-)

Jaguwar
0
 
mgfranzAuthor Commented:
Tha's why were here... :-)
0
 
clockwatcherCommented:
Personally, I'm here for the free t-shirts.  ;-)

That reminds me-- I've got to sign up as someone new now that I've hit the limit.
0
 
mgfranzAuthor Commented:
..Snicker... ;-)

Speaking of which...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now