HighDots Forums  

Question: Shorthand" CSS code?

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Question: Shorthand" CSS code? in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dave
 
Posts: n/a

Default Question: Shorthand" CSS code? - 08-22-2004 , 12:40 PM






Occasionally, I've seen people write CSS code in shorthand for specifying
font styles. I don't exactly remember how it goes, but sometimes I see
things like this:

SPAN {font: arial, helvetica 11 bold}...

I think this is a great idea, and I'd like to do some fine tuning of my own
code. Does anybody know where I can get an explanation of how this coding
strategy works? What about for multiple font names?

Any information is appreciated. Thanks!

--
============================
- Dave
http://members.cox.net/grundage/



Reply With Quote
  #2  
Old   
David Dorward
 
Posts: n/a

Default Re: Question: Shorthand" CSS code? - 08-22-2004 , 01:41 PM






Dave wrote:

Quote:
Occasionally, I've seen people write CSS code in shorthand for specifying
font styles. I don't exactly remember how it goes
So rtfm: http://www.w3.org/TR/CSS2/fonts.html#font-shorthand

Quote:
SPAN {font: arial, helvetica 11 bold}...
11 what? A unit is required, but no unit that could go there could be a good
choice.

Quote:
I think this is a great idea
It isn't that great - it means you have to remember things such as which
properties must be specified when you use the shorthand. It makes it easier
to introduce errors and harder to maintain.


--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is


Reply With Quote
  #3  
Old   
Neal
 
Posts: n/a

Default Re: Question: Shorthand" CSS code? - 08-22-2004 , 01:59 PM



On Sun, 22 Aug 2004 11:40:22 -0500, Dave <dave (AT) yahoo (DOT) com> wrote:

Quote:
Occasionally, I've seen people write CSS code in shorthand for specifying
font styles. I don't exactly remember how it goes, but sometimes I see
things like this:

SPAN {font: arial, helvetica 11 bold}...

I think this is a great idea, and I'd like to do some fine tuning of my
own
code. Does anybody know where I can get an explanation of how this coding
strategy works? What about for multiple font names?

Any information is appreciated. Thanks!


See http://www.w3.org/TR/CSS2/propidx.html for all CSS2 properties. You'll
find a number of shorthand possibilities, including font.

However, your above rule is flawed. Font-family comes last, and 11 has no
unit. It's not required, but advisable, to end your font family with a
generic.

span {font: bold 110% Arial, Helvetica, sans-serif}

Is it better? If you use the font shorthand all 5 the font-weight,
font-style, font-size and font-family are reset to their normal values
before the changes you make are set. So if you don't state all of these
values, you might expect a font-weight: bold to be inherited but it won't
be.

Like all shorthand styles, there are times it's the right tool for the
job, and times it's not.


Reply With Quote
  #4  
Old   
Dave
 
Posts: n/a

Default Re: Question: Shorthand" CSS code? - 08-22-2004 , 02:39 PM



Wouldn't the Arial, Helvetica, Sans-Serif be surrounded in quotes?

--
============================
- Dave
http://members.cox.net/grundage/
"Neal" <neal413 (AT) yahoo (DOT) com> wrote

Quote:
On Sun, 22 Aug 2004 11:40:22 -0500, Dave <dave (AT) yahoo (DOT) com> wrote:

Occasionally, I've seen people write CSS code in shorthand for
specifying
font styles. I don't exactly remember how it goes, but sometimes I see
things like this:

SPAN {font: arial, helvetica 11 bold}...

I think this is a great idea, and I'd like to do some fine tuning of my
own
code. Does anybody know where I can get an explanation of how this
coding
strategy works? What about for multiple font names?

Any information is appreciated. Thanks!



See http://www.w3.org/TR/CSS2/propidx.html for all CSS2 properties. You'll
find a number of shorthand possibilities, including font.

However, your above rule is flawed. Font-family comes last, and 11 has no
unit. It's not required, but advisable, to end your font family with a
generic.

span {font: bold 110% Arial, Helvetica, sans-serif}

Is it better? If you use the font shorthand all 5 the font-weight,
font-style, font-size and font-family are reset to their normal values
before the changes you make are set. So if you don't state all of these
values, you might expect a font-weight: bold to be inherited but it won't
be.

Like all shorthand styles, there are times it's the right tool for the
job, and times it's not.



Reply With Quote
  #5  
Old   
David Dorward
 
Posts: n/a

Default Re: Question: Shorthand" CSS code? - 08-22-2004 , 02:47 PM



Dave wrote:

Please direct your attention to http://www.allmyfaqs.com/faq.pl?How_to_post

Quote:
Wouldn't the Arial, Helvetica, Sans-Serif be surrounded in quotes?
No... as it says under font-family in the spec (which I referenced in my
last contribution to this thread).

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is


Reply With Quote
  #6  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Question: Shorthand" CSS code? - 08-22-2004 , 02:49 PM



"Dave" <dave (AT) yahoo (DOT) com> wrote:

Quote:
Wouldn't the Arial, Helvetica, Sans-Serif be surrounded in quotes?
Maybe in your code. But your posting style (upside-down fullquoting, and
a few other signals) suggests that you are not looking for constructive
comments. Anyway, here's one: quoting Sans-Serif would make sense only if
there were a font with the proper name "Sans-Serif". Of course, anyone
and his brother could design such a font (though hopefully couldn't
trademark it), but they haven't, so far.

--
Yucca, http://www.cs.tut.fi/~jkorpela/


Reply With Quote
  #7  
Old   
Neal
 
Posts: n/a

Default Re: Question: Shorthand" CSS code? - 08-22-2004 , 03:12 PM



On Sun, 22 Aug 2004 13:39:06 -0500, Dave <dave (AT) yahoo (DOT) com> wrote:

Quote:
Wouldn't the Arial, Helvetica, Sans-Serif be surrounded in quotes?


Please don't reply on top, and especially don't put quoted material in the
signature (under the --).

Quotes are only used to surround font names with spaces like "Times New
Roman" or "Arial BT". And by the way, I don't know for sure whether
Sans-Serif is incorrect, but the "proper" form is sans-serif. Remember,
it's not a name of a font. It's a generic font that cues the UA to use
whatever is the generic sans-serif font to render the text. For most UAs
this is Arial or Helvetica anyway, but it could be anything.


Reply With Quote
  #8  
Old   
Harlan Messinger
 
Posts: n/a

Default Re: Question: Shorthand" CSS code? - 08-23-2004 , 07:17 AM



"Dave" <dave (AT) yahoo (DOT) com> wrote:

Quote:
Wouldn't the Arial, Helvetica, Sans-Serif be surrounded in quotes?
Only if "Arial, Helvetica, Sans-Serif" is the name of a single font
family.

--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ๔ter le premier point de mon adresse de courriel.


Reply With Quote
Reply




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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.