View Full Version : style type help
Ben@WEBProp
08-11-2003, 04:33 PM
This may seem like a no-brainer question, but I cannot find any answers on my own for this one!
So I have this style in my page that makes a line of text that says "print this page" to not appear on the printout. I am currently trying to rip this style from the page and slap it into a .css document, but I am having some troubles with understanding how to go about it.
The line of code is:
<style type="text/css" media="print">
.dontprintme {display: none}
</style>
and the accompaning style is
<style type="text/css">
a {text-decoration: none}
</style>
As I am re-writting it into the .css file, what do I do with the media="print" part? Can someone just make these two styles into one class that is "p.noprint" for me?
My final question is:
Is there a way to make all default paragraphs into one font/size/margin/etc. easily? Right now I am using
p.normal {
blah: yay
blah: etc
}
and defining every paragraph as class="normal"...is there an easier way? I am using several paragraph styles, but mainly just one...if that matters...
Thanks for all your help with helping me to figure out css! I really appreciate it!
-Ben
MotherNatrsSon
08-11-2003, 06:09 PM
Is there a way to make all default paragraphs into one font/size/margin/etc. easily?
Put your font, size, margin in the body tag?
MNS
Ben@WEBProp
08-11-2003, 06:12 PM
Ah! MNS saves me again!
Actually, I was thinking more along the lines of in a .css document, so I don't have to go and change 5 billion pages every time I want to change the font size/family/etc...
-Ben
Ben@WEBProp
08-11-2003, 06:16 PM
Oh ya! And another thing in addition to my last 2 posts....
Can you link a .js file to a .css file? I have a textual tooltip script in a .js file, and as of now I fave everything in <font> and what not...but If I link it to the .css file, then they are easier to change...has anyone ever done this or run into this problem?
-Ben
MotherNatrsSon
08-11-2003, 06:21 PM
Originally posted by Ben@WEBProp
Ah! MNS saves me again!
Actually, I was thinking more along the lines of in a .css document, so I don't have to go and change 5 billion pages every time I want to change the font size/family/etc...
-Ben
You can do the same in a css doc.
<style type="text/css">
body { margin:0px;
font-family: verdana, sans serif;
font-size: 100%
}
</style>
MNS
Ben@WEBProp
08-11-2003, 06:27 PM
Right on...css is looking better and better to me!
So in my css, i will throw in a body {} part, but what about in my first post with the media="print"...how can I move that into a .css document? In the document itself, you don't use <style> tags and henceforth you don't use attributes for those tags in the normal sense...how do you specify the media="print" attribute in an external style sheet?
Thanks!
-Ben
MotherNatrsSon
08-11-2003, 06:35 PM
http://www.w3schools.com/css/css_mediatypes.asp
MNS
brothercake
08-11-2003, 07:03 PM
or you can go
<link rel="stylesheet" type="text/css" media="print" href="whatever.css" />
Ben@WEBProp
08-11-2003, 07:21 PM
I think that I want to consolidate everything to one style sheet, so I will use the @media...is that wise? Any drawbacks?
Also, lets say I have the following...
body
{
font-size: 70%;
color:#000000;
background-color:#f1f1f1;
margin-top:1px;
margin-left:1px;
margin-right:0px;
margin-bottom:0px;
}
Does this define just the <p> tag, or every single tag in the page? Also, if I have:
p
{
font-size: 90%;
color:#000000;
margin-top: 1px;
}
and I also have
p.somethingelse
{
font-size: 50%;
font-weight: bold;
margin-bottom: 30px
}
Will the p commands override the p.somethingelse? Which one takes priority if I have the class specified to somethingelse? Which takes piority in the case of body {} versus p {}?
Final clarifications: Does the body {} define everything in the page, or just the p element, or what? Who would win in a fight: a ninja or a samurai? How do I define in an external style sheet the styles of a link, visited link, active link, and so on? How can we have "prehistoric" things if we know the history of it?
Thanks for all the excelent help! More to follow...probably...
-Ben
:thumbsup:
brothercake
08-11-2003, 07:27 PM
Originally posted by Ben@WEBProp
so I will use the @media...is that wise? Any drawbacks?
yeah - it doesn't work in mac/ie5
ronaldb66
08-12-2003, 08:30 AM
Any properties that are inherited (see the W3C specs) and are specified for a parent element also apply to child elements; in case of the body element, all elements in it are in principle children and inherit those properties, like for instance font-family, font-size, etc.
When properties are specified for children, those properties will overrule the more general ones for the parent; adding an id or a class will increase the "weight" of a property,etc.
The W3C specs show how these "weights" are calculated.
When properties are of equal weight, the order in which they are specified will determine which one is used.
Update: for a nice (!) read, these are the relevant chapters in the CSS2 specs:
W3C CSS2: Selectors (http://www.w3.org/TR/REC-CSS2/selector.html) and
W3C CSS2: Assigning property values, cascading and inheritance (http://www.w3.org/TR/REC-CSS2/cascade.html).
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.