 |
| Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more. |
|
 |
08-16-2009, 09:42 PM
|
#1 (permalink)
|
|
v7n Mentor
Join Date: 08-08-09
Location: Barbados
Posts: 119
Latest Blog: None
|
Is There A Valid Reason NOT To Use Shorthand CSS Notation For Colors?
For several years now, I’ve noticed that style sheets for websites, designed by whom I would consider to be well seasoned pros, contain the long hexadecimal form of color names. Why go to the trouble of typing #FFAA00 when #FA0 would suffice? And why not #fa0 instead of #FA0?
Are the longhand and ALL CAPS forms more recognizable across browsers and platforms or something?
|
|
|
08-16-2009, 11:23 PM
|
#2 (permalink)
|
|
Super Moderator
Join Date: 10-29-07
Location: British Columbia, Canada
Posts: 3,299
|
I personally create my CSS file manually and type the properties out, including colour numbers. So I was curious about your question so Googled for some ideas as answers to your question:
From an Adobe article:
Quote:
...A key issue to note when using shorthand CSS, is that values omitted from a shorthand CSS property are assigned their default value. This may cause pages to be incorrectly displayed when two or more CSS rules are assigned to the same tag....
...If you have styles defined in more than one location (for example, both embedded in an HTML page and imported from an external style sheet) using both the short and long forms of CSS syntax, be aware that omitted properties in a shorthand rule may override (or cascade) properties that are explicitly set in another rule.
For this reason, Dreamweaver uses the long form of CSS notation by default. This prevents possible problems caused by a shorthand rule overriding a longhand rule....
|
Source: About Shorthand CSS properties
|
|
|
08-17-2009, 05:06 AM
|
#3 (permalink)
|
|
v7n Mentor
Join Date: 08-08-09
Location: Barbados
Posts: 119
Latest Blog: None
|
Quote:
Originally Posted by htmlbasictutor
I personally create my CSS file manually and type the properties out, including colour numbers. So I was curious about your question so Googled for some ideas as answers to your question:
From an Adobe article:
Source: About Shorthand CSS properties
|
Okay, so using the long form basically helps to error proof coding but what about the ALL CAPS? Is that just to help one visually locate colors quickly in bulky CSS code or are there browser/platform issues to consider?
|
|
|
08-17-2009, 09:12 AM
|
#4 (permalink)
|
|
v7n Mentor
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
|
there is no difference between all caps and all lowercase, or even in between. That's up to you and how you want your stylesheet to look. It's the same principle in HTML when doing tags.. ie you could do <P> or <p>.
But yes, as far as shorthand and longhand, I would always use longhand. If you use shorthand, there is a possibility different browsers will handle the color different. This is especially true in Mac's.
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|
|
|
08-17-2009, 09:20 AM
|
#5 (permalink)
|
|
Super Moderator
Join Date: 10-29-07
Location: British Columbia, Canada
Posts: 3,299
|
Quote:
Originally Posted by Izzmo
...It's the same principle in HTML when doing tags.. ie you could do <P> or <p>....
|
When coding for XHTML, elements and attributes are in lower case.
Quote:
4.2. Element and attribute names must be in lower case
XHTML documents must use lower case for all HTML element and attribute names. This difference is necessary because XML is case-sensitive e.g. <li> and <LI> are different tags.
|
Reference: 4. Differences with HTML 4 - XHTML 1.0 specification
Differences Between XHTML And HTML
|
|
|
08-17-2009, 11:16 AM
|
#6 (permalink)
|
|
v7n Mentor
Join Date: 08-08-09
Location: Barbados
Posts: 119
Latest Blog: None
|
Okay. Thanks for the feedback, guys.
To be on the safe side, I’ll change all of my shorthand color codes to longhand. However, my markup has always been lowercase to ensure validation because all of my sites are XHTML 1.0 (Strict). And since its easier to type all lowercase anyway, I got into the habit of typing my CSS like that too (although I have a vague recollection of reading somewhere that font names - or is it font family names? - should start with capital letters for better browser support).
Last edited by abajan; 08-17-2009 at 11:21 AM..
|
|
|
08-17-2009, 11:09 AM
|
#7 (permalink)
|
|
v7n Mentor
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
|
I understand that, it will not validate, but it will still work. (Just stating a overall basic principle.. not validation rules or how to code correctly)
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|
|
|
08-17-2009, 12:47 PM
|
#8 (permalink)
|
|
v7n Mentor
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
|
XHTML has nothing to do with CSS.
CSS, IMHO, should be uppercase for things like color-codes. But lower case for any attributes.
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|
|
|
08-17-2009, 02:33 PM
|
#9 (permalink)
|
|
v7n Mentor
Join Date: 08-08-09
Location: Barbados
Posts: 119
Latest Blog: None
|
Quote:
Originally Posted by Izzmo
XHTML has nothing to do with CSS.
CSS, IMHO, should be uppercase for things like color-codes. But lower case for any attributes.
|
I didnt imply XHTML had anything to do with CSS. Its just faster to type everything in lowercase.
|
|
|
08-17-2009, 08:22 PM
|
#10 (permalink)
|
|
v7n Mentor
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
|
True, it is.
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 03:36 PM.
© Copyright 2008 V7 Inc Powered by vBulletin Copyright © 2000-2009 Jelsoft Enterprises Limited.
|
|
|