CodeIgniter Forums
Formatting Tables with CSS - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Formatting Tables with CSS (/showthread.php?tid=29631)

Pages: 1 2


Formatting Tables with CSS - El Forum - 04-16-2010

[eluser]pickupman[/eluser]
[quote author="John_Betong" date="1271412331"] 
Try this:
Code:
// old
    <tr class="&lt;?php echo alternator('alt,'');?&gt;">

  // New
    <tr style="&lt;?php echo alternator('background:#cfc','background:#ffc'); ?&gt;">
&nbsp;
&nbsp;
&nbsp;
edit: added missing #[/quote]
Inline style is bad practice as it is a pain to go back and edit the colors. Best to use a css class.


Formatting Tables with CSS - El Forum - 04-16-2010

[eluser]John_Betong[/eluser]
[quote author="maniac" date="1271436840"]Sorry, what do you mean?[/quote]

Ideally you should have a CSS file linked in to your web page with a class named .alt

There are many advantages of storing all your CSS statements in a style sheet rather than having inline CSS statements.

Check out W3Schools.com for a comprehensive explanation.
&nbsp;
&nbsp;
&nbsp;


Formatting Tables with CSS - El Forum - 04-16-2010

[eluser]maniac[/eluser]
Used the first suggestion and got it working. I originally wrote the class as alternator instead of alt.

Thank you for all your help and patience.

Maniac


Formatting Tables with CSS - El Forum - 04-17-2010

[eluser]John_Betong[/eluser]
[quote author="maniac" date="1271483612"]Used the first suggestion and got it working. I originally wrote the class as alternator instead of alt.

Thank you for all your help and patience.

Maniac[/quote]
&nbsp;
&nbsp;
Just came across this web page that details four different methods of using CSS, their individual benefits and/or drawbacks.

http://matthewjamestaylor.com/blog/adding-css-to-html-with-link-embed-inline-and-import
&nbsp;
&nbsp;
&nbsp;