• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CSS ????

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am building a jsp site and decided to use CSS to format the pages. This is my first experience with CSS, so forgive me if this is a simple question. From what I have read, you should put the formatting definitions such as <B>, <font color="#DFDFDF">, etc into the CSS file. You should then be able to override the settings in the css by putting the formatting directly into your jsp file. Therefore, I am putting the formatting that will be used 99% of the time in the CSS. When I have a special case that needs special formatting, I put that special formatting directly into the jsp file. However, when I view the file, the special formatting is not recognized; it still uses the formatting defined in the CSS file. What do I need to do so that the formatting in the jsp file overrides what is defined in the CSS?
Thanks for your help.
 
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem CSS is that it is very much browser dependent.
You can override global style definitions in your external CSS file by using the inline "style" attribute against particular tags.
eg.
say your global CSS definitions were:
<style ...>
h1 {
color:red;
font-size:15pt;
}
...
</style>
normally if you applied this style sheet to your HTML page, each <h1> tag would have red text of size 15pt.
To override this use the inline style attribute.
eg.
<h1 style="color:black;font-size:10pt;...">
Also note, if you mix "old-school" display formatting tags (<b>,<font>, etc) with CSS formatting you will get unpredictable results that will depend on your browser for how it will be rendered.
Hope this helps,
James.
 
verduka fox
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
James,
Thanks for your reply. A couple follow - up questions:
1) "CSS is very much browser dependent." For the time being, our site will be on IE5. In the future, we will also support Netscape. What types of differences are there? Would I be safer to use "old school" formatting instead of css? What should I look out for in this case of supporting two browsers?
2) Where do I put the inline style attribute? Immediately before I want to change it? What do I do to revert back to the css definition after my one special case?
Thanks for your help.
 
James Swan
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Verduka,
1)
The type of differences are shown here http://www.webreview2.com/style/mastergrid.shtml
I guess try to keep things simple, use "safe" tags (eg. <div>, <span> ) that have CSS properties well supported by different browsers.
A common approach, is to use browser detection at the client or server and then determine if you will apply your CSS or not.
eg. if (http_user_agent is IE5.x) {
use nice CSS formatting;
} else {
revert to "old-school" formatting;
}
Sorry this doesn't answer all of your questions, but this is a large topic, there are plenty of resources on the Internet that discuss this in more detail.

My advice is to try things out for yourself, have a couple of different browsers installed on your workstation, see what works and what doesn't.
2)
The inline style attribute only applies to the tag it was defined in, so in the example I gave, if you used another <h1> tag with no "style" attribute it would default to using the global styles set up in the CSS file.
This is can be a rather large topic on how "cascading" of style sheets is applied.
James.
 
reply
    Bookmark Topic Watch Topic
  • New Topic