...

View Full Version : Style Sheets - When do I use them?



bacterozoid
10-28-2002, 09:48 PM
Now, first of all: I know what CSS is, and I am familiar with some of its uses and how to use it. What I am curious about is how the world is using them now. In general, I use HTML to lay out my documents, stick tables, text, etc. inside my document. I have really only used CSS for scrollbar color and dynamic links. Few questions:

Should I be putting these properties into an external stylesheet which loads into my document?

How compatible is CSS between different browsers? (IE handles it fine, but Netscape, Mozilla, Opera are questionable to me.)

Should I use more CSS in my documents for everything but simple HTML layout tags?

Basically it, might have some more later, but I don't use a whole lot of CSS and haven't bothered learning it, but I might just take it up. Thanks for any help!

zoobie
10-28-2002, 09:52 PM
Well, you can use them anyway you wish. What's nice is calling on an external sheet for style and changing your sites appearance every-so-often by editing just the sheet.

Best to read up on them. :D

bacterozoid
10-28-2002, 09:53 PM
Sure, but I gotta stay 'hip' heh. That I do realize. I have made good use of external .js files. Love em. :) Got one question answered! Or at least one answer to one question..thanks!

BrainJar
10-28-2002, 10:55 PM
Netscape (6+), Mozilla and Opera all support CSS better than IE. I'd really recommend trying out one or more of those browsers just so you can see some of the more advanced features in CSS.

The current direction is to move presentational markup out of HTML and rely on CSS instead. HTML/XHTML should be used for structuring your content. Style sheets can then be used to define how it looks.

bacterozoid
10-28-2002, 11:01 PM
Netscape (6+), Mozilla and Opera all support CSS better than IE.

Really? I had no clue. I shall have to try that out. I see more now than ever the relevence of CSS. I tried out a few things with stylesheets, and it could really clean up some of my documents.

jkd
10-28-2002, 11:07 PM
Originally posted by BrainJar
Netscape (6+), Mozilla and Opera all support CSS better than IE.

Well, IE/Windows.

Internet Explorer 5 for Mac has surprisingly excellent support for CSS, considering its Windows counterpart. :)

Kiwi
10-28-2002, 11:11 PM
A bunch of points.

Mozilla based browsers are far better in their support of CSS than IE (as has already been noted).

Secondly, a lot of the HTML formating tags have been depreciated, meaning they may not be included in future browsers. This includes <center>, <font>, <b> and <i>. These tags should all be replaced with CSS (either in-line or using classes).

External style-sheets are cached, meaning that a style-sheet will only be downloaded once, no matter how many times it is used. On a large site, this can add to the speed of the page loads after the first. I usually put site-wide styles into an external style-sheet, then add any page specific styles to a style declaration on a given page. I tend not to use in-line styles very much -- I find them too messy.

Style-sheet make it much easier to make site-wide changes. I write my sites using the various <hn> tags and a bunch of classed paragraphs, tables and divs. If I want to change the layout of my site (include the size of the core tables that lay-out the site), I can make these changes in one file.

You can change style properties with javascript -- so simple roll-overs can be done without any graphics. This is a far more powerful way of controlling the appearance of your site (incidentally, the core .js should also be external, which also allows it to be cached).

dauvm
10-28-2002, 11:25 PM
definately... changing to XHTML (strict HTML,very easy to learn) and CSS totally cleans up your code like you wouldn't believe. If you like external .js files, you would love php! you write a page with an external style sheet, and then split it in half, one everything about where your content goes and one everything below, then save one as top.html and the other one as bottom.html and then write your normal page like

<?php
include('top.php');
?>
this is all the text that would go into the middle of your page, or inside your content table, or whatever.
<?php
include('bottom.php');
?>

and name the page something.php and then you're done! you change the content by changing what's right in there and you change the style of anything by changing the external .css file.

ok this isn't really usefull or on topic but I think you'll enjoy playing w/ it, and it does go to show how removing extranious material from what you're actually working on can make life easier. That's what css is for; seperation of structure and presentation.

-Doug

Kiwi
10-28-2002, 11:37 PM
I do like php, although it's often very poorly used. There's too often a confusion of logic, data and presentation. Given how powerful it is, it's too often used very badly.

Still, I often complain about poor programme structure/architecture.

bacterozoid
10-29-2002, 12:06 AM
Well I'm glad I posted this. PHP sounds really interesting. This stuff could start to get real fun. I shall have to set aside some time to learning CSS, and then PHP...and probably finishing up JavaScript ;) As for newer browsers removing those tags...ick. I can see why they do it though. I have read something on making CSS the default language of the web...and by the looks of things, things are heading in that direction. HTML used to be so cool. Glad I learned about this stuff 4 years ago. I'm much better off. Thanks for all the comments, made me seriously consider a few things.

zoobie
10-29-2002, 02:50 AM
Originally posted by BrainJar
Netscape (6+), Mozilla and Opera all support CSS better than IE.

You may want to mention that only 1% use NS6 while 92% use IE5+. :D

jkd
10-29-2002, 03:20 AM
Originally posted by zoobie


You may want to mention that only 1% use NS6 while 92% use IE5+. :D

How does that affect the fact that IE/Windows has the worst CSS support of any significant web browser?

allida77
10-29-2002, 01:39 PM
How does that affect the fact that IE/Windows has the worst CSS support of any significant web browser?

It doesnt but if 90% are using IE5+ then that is what you should be coding for. If you are coding for anything else you are wasting yours and your clients time and making things more difficult than they should be.


Should I use more CSS in my documents for everything but simple HTML layout tags?

Along with what has already been said I say just be consistent. It can get annoying if you are working on someone elses code and they put half of their styles inline, half in their external .css, and half in their style declaration. I guess it is more of a preference and how many styles you are putting in your page. If you are using a large amount of css on a page than you will want to make an external css to reduce file size.

redhead
10-29-2002, 02:14 PM
Originally posted by bacterozoid
... CSS, and then PHP...and probably finishing up JavaScripti found it easier to learn JavaScript first... it leads on well to the basics of PHP, so does C+ etc i'm told....

jkd
10-29-2002, 04:47 PM
Originally posted by allida77
If you are coding for anything else you are wasting yours and your clients time and making things more difficult than they should be.

If you code to standards, you can be assured of it working several years down the line in whatever the popular browser(s) may be.

In actuality, you are saving you and your client's time and money.

redhead
10-29-2002, 05:43 PM
Originally posted by allida77
but if 90% are using IE5+ then that is what you should be coding for. If you are coding for anything else you are wasting yours and your clients time and making things more difficult than they should be.

that leaves 10% with a half-hearted attempt at web design, and you need to remember that if you are getting 1000 hits, that is 100 potential customers leaving knowing that whoever made the site couldnt be bothered to do their job properly.

that is why i make sure that i code perfectly for 99%+ of visitors.

allida77
10-29-2002, 05:46 PM
I am not saying to ignore 10%, you should code for the 90% first and then focus on the other 10%.

brothercake
10-29-2002, 07:53 PM
Originally posted by jkd
If you code to standards, you can be assured of it working several years down the line in whatever the popular browser(s) may be.

Come on mate .. you know that isn't true. As if you can just rely on future browsers being compliant rather than them being future version of IE ... as if the standards themselves won't have changed in a way that might not be backwardly-compatible ... as if the content and design won't have completely changed in that time anyway ...

I try to stick to standards, but I'm quite happy to abandon them in favour of proprietary hacks if its quicker/easier/more efficient/otherwise prefererable to do so.

bacterozoid
10-29-2002, 09:51 PM
i found it easier to learn JavaScript first... it leads on well to the basics of PHP, so does C+ etc i'm told....

Away from our current arugument, I have heard that before, yes, so I better try out JavaScript first. ;)

Online with the ongoing debate: I think that when you code a page you should build espicially for Microsoft Internet Explorer, being it that most people use it, but also keep high in mind the appearance and function of the page on any other major browser. Like has been said, if you code for MSIE and a Netscape user has problems with your page, then you lost that person.

As well, our current standards for web pages are likely to change further down the road. Browsers in the future might likely start to accept only CSS, and no special HTML tag attributes. I'm sure there will be many other changes, but if you really think back, are today's standards the same as what they were 10, 20 years back?

BrainJar
10-31-2002, 03:29 PM
IE may not have the best standards support, but it's not completely off either. Microsoft does seem to be moving closer, if slowly. They are a member of the W3C.

You can still make pages that follow the standards and look decent on IE, although an occasional hack may be necessary.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum