Forums / Contribution-Writing Guidelines / Inline css or separate file

Inline css or separate file

Locked

Started by gilby on 5 Jun 2006, 10:11 AM · Views: 5,550

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
5 Jun 2006, 10:11 AM
#1
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Inline css or separate file

Whats the best way for a contrib?

I am working on a sidebox, the content of which needs to be centered or padded into the middle.

  1. Inline css to pad to the centre

  2. Another separate css file with one entry to do the padding

  3. Give instructions on adding the css to the main css file.
    Means editing a file so is not plug and play. :no:

4 Surround it with a table, one cell that is centered :yuck:

The simplest is the inline css and doesn't involve loading another css file.
The separate css file makes it easier to alter!

Any guidelines on the best way to do it?

5 Jun 2006, 11:36 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Inline css or separate file

If this is a new sidebox, I would assign it a class, then define the style that could be copied and pasted to the stylesheet.css

If you are refering to a sidebox already created by Zencart, you would still need to differentiate this box only as different than .sidebox, sidebox container etc.

Unless there is a tpl file specifically for this box I can see no way to use an inline style that would apply only to this box.

Zen-Venom Get Bitten

5 Jun 2006, 12:01 PM
#3
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: Inline css or separate file

kobra:

If this is a new sidebox, I would assign it a class, then define the style that could be copied and pasted to the stylesheet.css

If you are refering to a sidebox already created by Zencart, you would still need to differentiate this box only as different than .sidebox, sidebox container etc.

Unless there is a tpl file specifically for this box I can see no way to use an inline style that would apply only to this box.

I am basically reworking a google adsense sidebox and it has its own tpl file. Also modified so it only shows on non ssl pages as if they are on an ssl page then you don't want customers distracted & leaving when they might be buying something.

I was wondering if there is a standard to conform to. Would have prefered not to have to to edit files if possible, I like the idea of copying files to install & deleting files to remove.

5 Jun 2006, 12:19 PM
#4
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Inline css or separate file

gilby:

Whats the best way for a contrib?

I am working on a sidebox, the content of which needs to be centered or padded into the middle... Any guidelines on the best way to do it?

In regards to 1.3x based shops you have likely already located /includes/templates/template_default/css/CSS_read_me.txt. It does not directly respond to your inquiry but may help.

Assuming the mod is for 1.3x shops, and assuming the sidebox will display most/all of the time, and since you are only referring to one single style, adding the style to the main stylesheet is appropriate. Indeed if you expect the style will never ever require adjustment by the shop owner, you can "get by" with inline CSS or a separate style sheet. But these days I avoid inline when possible, even if "at first" it is most easy for me as developer, and you/me as shop owner. And I avoid going with a separate stylesheet, unless the style is only relevant to specific page(s) and/or is language dependent and/or the style does not need to be loaded constantly. Too many external style pages can become overly confusing.

On the contrary the default 1.3.0.1 stylesheet.css is 11KB (and likely larger if working on a heavily customized shop). And with separate stylesheets for third party mods, it is easy to identify/remove styles when/if the mod is ever uninstalled (rather than allowing the unneeded style info linger in the main stylesheet for eternity).

Opportunity costs in everything. So pick your poison ;)

Thanks to the updated div/id/class code in 1.3x, and with tools like Web Developer available, shop owners can now easily experiment with their shop CSS to match their creative desires. So when possible going the main stylesheet route is the way to go and generally pays off in the end if the custom style info is well documented within the stylesheet. (ease of maintenance).

Woody

5 Jun 2006, 12:32 PM
#5
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Inline css or separate file

Gosh, Woodymon said that alot better than I did...

Zen-Venom Get Bitten

5 Jun 2006, 12:46 PM
#6
woodymon avatar

woodymon

Totally Zenned

Join Date:
Sep 2004
Posts:
2,309
Plugin Contributions:
1

Re: Inline css or separate file

kobra:

Gosh, Woodymon said that alot better than I did...

Uhhh.... Actually I didn't. I did not see that you had responded when I posted. You were much more specific whereas I was more general.

6 Jun 2006, 3:17 AM
#7
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: Inline css or separate file

Thanks all for your comments.

For better or Worse.....

I've made my decision! :wacko:

Decided on the one line of inline css to format the sidebox, so that it would be backwardly compatible with 1.27d with no editing of css files required.

See the result in downloads Google Adsense Sidebox

Of course the most important part of this release is hidden (DaVinci Code Style) in the php files and the purpose of the box. :eek: