473,324 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

CSS specific for modular code- theory question

I have some modular code that is written for display purposes. It
contains inline CSS code. I originally thought about moving all the
inline code to a css file for use throughout the site- one css file
with all the site's code. However this would hurt the code's
portability throughout multiple sites. Does anyone know of a good
article (or does anyone have strong opinions) about how to organize
styles in modular code. The code in question is a ColdFusion component
(like ASP.NET), but I think this CSS topic can relate to any language.

So do I move the code to a central CSS file with documentation on the
styles or do I leave it be? Can I default to a css file first? I
think inline css always takes precedence.

thanks,

Don

Nov 23 '05 #1
4 1348
bb*****@gmail.com wrote:

So do I move the code to a central CSS file with documentation on the
styles or do I leave it be? Can I default to a css file first? I
think inline css always takes precedence.

By all means document your styles. Place the primary stylesheet that
defines the overall style for the site in a standard location. Add
specific stylesheets for specific situations.
The last applicable style encountered wins.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Nov 23 '05 #2
bbcrock wrote:
I have some modular code that is written for display purposes. It
contains inline CSS code.


Take out the inline styles. Add lots and lots of classes and IDs -- more
than you could possibly want. Distribute your module with a sample
stylesheet that uses these classes and IDs.

For bonus points, give all your classes and IDs a common prefix. e.g.

<div id="bbcrockcode_ident_flibble" class="bbcrockcode_wrapper">
<h1 class="bbcrockcode_heading">Foo</h1>
</div>

and make sure that this common prefix can easily be changed. e.g.

<?php
$prefix = "bbcrockcode_";
$idprefix = "bbcrockcode_ident_";

function printflibble ()
{
global $prefix, $idprefix; // globals are evil
print "<div id=\"{$idprefix}flibble\" "
. "class=\"{$prefix}wrapper\">\n"
. " <h1 class="{$prefix}heading">Foo</h1>\n"
. "</div>\n";
}
?>

This will prevent clashes of class names, IDs etc when integrating your
module into some other site.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Nov 23 '05 #3
"Toby Inkster" <us**********@tobyinkster.co.uk> wrote in message
news:hu************@ophelia.g5n.co.uk...
bbcrock wrote:

For bonus points, give all your classes and IDs a common prefix. e.g.

<div id="bbcrockcode_ident_flibble" class="bbcrockcode_wrapper">
<h1 class="bbcrockcode_heading">Foo</h1>
</div>

and make sure that this common prefix can easily be changed. e.g.

<?php
$prefix = "bbcrockcode_";
$idprefix = "bbcrockcode_ident_";

function printflibble ()
{
global $prefix, $idprefix; // globals are evil
print "<div id=\"{$idprefix}flibble\" "
. "class=\"{$prefix}wrapper\">\n"
. " <h1 class="{$prefix}heading">Foo</h1>\n"
. "</div>\n";
}
?>
This is OT I know, but since I too smear PHP/HTML/CSS together, I will just
say I'd prefer to see:

<?php
define( 'PREFIX', "bbcrockcode_" );
define( 'IDPREFIX', "bbcrockcode_ident_" );

function printflibble ()
{
......
}
?>

which gets rid of the global statement and reduces the possibility of one's
globals getting accidently changed. The question of capitalizing the names
of globals is strictly a personal preference thing.
Nov 23 '05 #4
Toby Inkster wrote:
Take out the inline styles. Add lots and lots of classes and IDs -- more
than you could possibly want.


Oh... and then add some more.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dan Stromberg | last post by:
Is there already a pure python module that can do modular-arithmetic unit conversions, like converting a huge number of seconds into months, weeks... or a bandwidth measure into megabits/s or...
18
by: Zero | last post by:
Hi, I am calculating an integer to the pwer of a large integer, e.g. 2^5000. It turns out that the result I always get is zero. I am sure that the result is too large to store in such type...
4
by: Nick Goloborodko | last post by:
Hi, I'm in the process of conceptualizing a new ASP.NET application. I'm a relative newbie in ASP.NET / .NET in general, so any comments will be greatly appreciated. Basically i need to make...
12
by: Don Huan | last post by:
Hi my job is to migrate our WinForms application to ASP.NET. This app was build very modular so every peace of code can be replaced by another "modul". There are 1 VS-solution with about 60...
26
by: I_AM_DON_AND_YOU? | last post by:
This is the scenario: I have a VB.Net project comprising of a few Forms. On Form1 I have more than 20 buttons. There is a very lenghty code written in click event of each and every button. Right...
20
by: Tuvas | last post by:
I have made and recently posted a libary I made to do Modular Arithmetic and Prime numbers on my website at http://www.geocities.com/brp13/Python/index.html . I am currently in a crypotology...
2
by: Tyno Gendo | last post by:
I'm writing a test "modular site". So far I have created an App class, a Module Manager class and a couple of test modules. The Manager looks in a directory called 'modules' and then for every...
1
by: mattgarvin | last post by:
Hello, my company hosts many websites, and we want to add a Feedback Form (like "Contact Us") that can be re-used on all of them just by "dropping in" a new directory containing the code. My boss...
16
by: Nkhosinathie | last post by:
hi, i'm writing a program that is using 4 arrays of pointers to char,called article,noun,verb and preposition.the program should create a sentence by selecting a word at random from each array in the...
1
by: bob | last post by:
I have made a file: box.h that have some structs, simple functions etc. I have then made another file: print.h that have a class 'print' with methods to print the content from 'box' (content of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.