473,656 Members | 2,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TD CSS Shorthands... Thoughts?

Hello! :)
I am working on an app that uses dozens of tables, some with hundreds
(or even thousands!) of rows. I am interested in formatting the tables
using as much CSS as possible, so the HTML is barebones and
easy-to-read/modify. While thinking up how to do it, I came up with
this idea, which I welcome comments on:

QUESTION: What are the pros and cons of using one letter class names
for common TD cell formatting, like "nowrap" or "align=righ t", etc.

Something like this:

..l { text-align : left; }
..c { text-align : center; }
..r { text-align : right; }

..t { vertical-align : top; }
..m { vertical-align : middle; }
..b { vertical-align : bottom; }

..w { white-space : wrap; }
..nw { white-space : nowrap; }

This would enable you to do "shorthand" for formatting cells, like
this:

<td class="c t nw">100 million</td>

where this particular cell centered horizontally, middled vertically,
and with no wrapping...

What do you think?

My biggest fear is it will get expensive processor-wise.

Anyone done something like this, who would care to comment, good or
bad?

Thank you,
Ann

Apr 27 '06 #1
36 1901
Giggle Girl wrote:
Hello! :)
I am working on an app that uses dozens of tables, some with hundreds
(or even thousands!) of rows. I am interested in formatting the tables
using as much CSS as possible, so the HTML is barebones and
easy-to-read/modify. While thinking up how to do it, I came up with
this idea, which I welcome comments on:

QUESTION: What are the pros and cons of using one letter class names
for common TD cell formatting, like "nowrap" or "align=righ t", etc.

Something like this:

.l { text-align : left; }
.c { text-align : center; }
.r { text-align : right; }

.t { vertical-align : top; }
.m { vertical-align : middle; }
.b { vertical-align : bottom; }

.w { white-space : wrap; }
.nw { white-space : nowrap; }

This would enable you to do "shorthand" for formatting cells, like
this:

<td class="c t nw">100 million</td>

where this particular cell centered horizontally, middled vertically,
and with no wrapping...

What do you think?
I do it all the time. Works fine.
My biggest fear is it will get expensive processor-wise.
How so?
Anyone done something like this, who would care to comment, good or
bad?


See above :)
Apr 27 '06 #2
Giggle Girl wrote:
Hello! :)
I am working on an app that uses dozens of tables, some with hundreds
(or even thousands!) of rows. I am interested in formatting the tables
using as much CSS as possible, so the HTML is barebones and
easy-to-read/modify. While thinking up how to do it, I came up with
this idea, which I welcome comments on:

QUESTION: What are the pros and cons of using one letter class names
for common TD cell formatting, like "nowrap" or "align=righ t", etc.

Something like this:

.l { text-align : left; }
.c { text-align : center; }
.r { text-align : right; }

.t { vertical-align : top; }
.m { vertical-align : middle; }
.b { vertical-align : bottom; }

.w { white-space : wrap; }
.nw { white-space : nowrap; }

This would enable you to do "shorthand" for formatting cells, like
this:

<td class="c t nw">100 million</td>

where this particular cell centered horizontally, middled vertically,
and with no wrapping...

What do you think?
The point of using styles is to separate content from presentation. One
of the advantages of that is that you can change the appearance entirely
by altering the stylesheet without having to touch the HTML, and in
particular without having to hunt through it and make changes to every
element whose appearance you want to alter.

If you put classes in your HTML that refer directly to appearance, then
suppose you decide you want all the cells that used to be right-aligned
to be center-aligned. You have to go through your HTML and change all
the classes. You *could* just change one line in your CSS to read

.r { text-align : center; }

if you meant for the change to be universal. But that would be silly,
wouldn't it?

Unless your cell formatting is completely haphazard, the changes are
that you are applying these styles for a reason. Perhaps you want
numeric cells to be top-right-aligned, and you want column headers to be
bottom-center-aligned. So what would make sense would be to designate
cells with class="numeric" and class="colhead" and then have

.numeric { text-align: right; vertical-align: top; }
.colhead { text-align: center; vertical-align: bottom; }
My biggest fear is it will get expensive processor-wise.


Not particularly.
Apr 28 '06 #3
On 27 Apr 2006 13:17:24 -0700, "Giggle Girl" <mi*******@gmai l.com>
wrote:

: My biggest fear is it will get expensive processor-wise.

How much do you play for each millisecond?

Sid
Apr 28 '06 #4

Giggle Girl wrote:
QUESTION: What are the pros and cons of using one letter class names
for common TD cell formatting, like "nowrap" or "align=righ t", etc.


Dreadful! Total mis-use of CSS.

CSS is about _styles_ Not about attaching individual inline CSS
properties to every element that uses them. That approach would couple
content and presentation together as closely and badly as doing it with
<font> tags.

I also doubt if you really need per-cell control of random formatting
combinations. If there isn't some overall consistency here, then it's a
funny sort of table. If you have this consistency, then label its scope
(i.e. rows as "odd" or "even") and then bind the CSS properties to the
CSS classes in the stylesheet, where it belongs.

One letter class names are OK, but don't actually gain you that much.

Apr 28 '06 #5
On Fri, 28 Apr 2006, Andy Dingley <di*****@codesm iths.com> wrote:
(i.e. rows as "odd" or "even")


Isn't it a pity that there's no way to specify that (for rows or
columns) directly in CSS?

The nearest I've got to it is specifying styles for e.g:

tr, tr+tr+tr, tr+tr+tr+tr+tr etc. for the odd rows,
tr+tr, tr+tr+tr+tr etc. for the even rows.

OK, so assigning a class to the *rows* would be no big deal; but when
you want to style the *columns* too, then it gets to be a chore (and a
waste of HTML) having to add class=odd|even to every wretched cell.
Then the tr+tr+tr or td+td+td selectors seem to me, out of the
available toolkit, to be quite a tolerable compromise.

(Forgetting the browser-like operating system component for now, of
course).

http://ppewww.ph.gla.ac.uk/~flavell/tests/tablefun.html for a
small and simple demo "which I made earlier".
Apr 28 '06 #6
Alan J. Flavell wrote:
Isn't it a pity that there's no way to specify that (for rows or
columns) directly in CSS?


Given the negligible support of the attribute selectors we do have,
then I doubt it would matter much whether there ought to be or not.

I handle this sort of task with XSLT. Long-winded CSS is no problem to
me, I just add it at the step before.

Apr 28 '06 #7
On Fri, 28 Apr 2006, Andy Dingley <di*****@codesm iths.com> wrote:
Alan J. Flavell wrote:
Isn't it a pity that there's no way to specify that (for rows or
columns) directly in CSS?


Given the negligible support of the attribute selectors we do have,
then I doubt it would matter much whether there ought to be or not.

I handle this sort of task with XSLT. Long-winded CSS is no problem to
me, I just add it at the step before.


Oh, sure: long-winded HTML (i.e in this case with a class= on every
damned table cell) is also no problem to anyone who can write a
program to spew it out. But it's more a matter of taking a little
pride in what one extrudes out onto the world wild web - - and I'm
sure you really feel that way yourself, despite your occasional
remarks that might be interpreted to suggest otherwise :-}

Apr 28 '06 #8

Alan J. Flavell wrote:
But it's more a matter of taking a little
pride in what one extrudes out onto the world wild web - - and I'm
sure you really feel that way yourself, despite your occasional
remarks that might be interpreted to suggest otherwise :-}


I'm pragmatic. If ugly is the best the standard offers and it works,
then I'll make ugly. _Publishing_ live sites on the web is no place
for arguing as to how things ought to be, you just have to work with
what you have.

Apr 28 '06 #9
Andy Dingley <di*****@codesm iths.com> wrote:
Alan J. Flavell wrote:

But it's more a matter of taking a little
pride in what one extrudes out onto the world wild web - - and I'm
sure you really feel that way yourself, despite your occasional
remarks that might be interpreted to suggest otherwise :-}

I'm pragmatic. If ugly is the best the standard offers and it works,
then I'll make ugly. _Publishing_ live sites on the web is no place
for arguing as to how things ought to be, you just have to work with
what you have.


Another pragmatic POV:

I write HTML, JavaScript & CSS as the client-side rendering, and there
are a team of developers who use what I write to make the application
work. If I can provide simple classes like .r { text-align:right; } for
them to place programatically as THEY need it, it simplifies the work
for everyone involved. And if you store that class declaration as a
constant, then all you have to do is change that single constant to
change the way the site renders.

Granted, it's not exactly what CSS is best for, but sometimes you make
the best use of the tools to accomplish a task it was never intended to
accomplish.
Apr 28 '06 #10

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

Similar topics

30
2140
by: Stephen Horne | last post by:
Some more looping thoughts - this time on integer for loops... There may be some hint towards PEP284 (integer for loops) in a review of ideas from other languages, but I'm damned if i can figure it out. I spent some time thinking about it and couldn't find anything that would cover the issue. All I came up with was the recognition that some other languages have 'for' and 'foreach' loops. But Python went down the route of using 'for'...
39
3156
by: Marco Aschwanden | last post by:
Hi I don't have to talk about the beauty of Python and its clear and readable syntax... but there are a few things that striked me while learning Python. I have collected those thoughts. I am sure there are many discussions on the "problems" mentioned here. But I had this thoughts without looking into any forums or anything... it is kind of feedback.
1
1501
by: Steve | last post by:
I'm still a database newbie so I would like to solicit thoughts about the smartest way to do something in sqlserver. My company has a web application that we customize for each client. We can do this because everything is database driven. We have database tables that contain our HTML and database tables as well as some standard tables for each database. We have an in house app that lets us tweak both of these things and creates a new...
4
1496
by: Rajan | last post by:
Hi All C++ Experts Can anybody share some of your thoughts in Member Function Templates implementation.Can you also give some example on it Best Regards Raj
2
1130
by: Ian | last post by:
Hi there, I wanted to get anybodys thoughts on using the following... <script src="http://test.com/myscript.js"></script> for including functions etc in the html page, of course I could embed all the functions but wondered if anybody thinks that this is a more organised way or should I stay clear and always insert the function of javascript directly into the html
35
1875
by: Justin Weinberg | last post by:
My thoughts on this.... http://msdn.microsoft.com/vbasic/Future/default.aspx?pull=/library/en-us/dnvs05/html/vb9overview.asp My thoughts: 1. Regarding Implicit types, I don't use type declaration for the benefits of performance. It's for the benefit of clarity of purpose when reading code. The first thing I do with neophyte developers is turn Option Strict
36
1584
by: Giggle Girl | last post by:
Hello! :) I am working on an app that uses dozens of tables, some with hundreds (or even thousands!) of rows. I am interested in formatting the tables using as much CSS as possible, so the HTML is barebones and easy-to-read/modify. While thinking up how to do it, I came up with this idea, which I welcome comments on: QUESTION: What are the pros and cons of using one letter class names for common TD cell formatting, like "nowrap" or...
2
1669
Stang02GT
by: Stang02GT | last post by:
Hello, I would just like to get your thoughts/ideas/suggestions on how I should go about createing a VERY SIMPLE purchasing system. A friend has asked me help him develop a simple purchasing database. Just off the top of my head this is what i have come up with for the table lay out. Tables = Bold Text Customer Name
1
1404
Stang02GT
by: Stang02GT | last post by:
Hello, I'm looking for your thoughts, ideas, and suggestions on this situation. I have recently been given the task to "fix" a menu within the companies intranet site. The current menu operates such that when you place your mouse over a category in the menu, a sub menu will then appear. Some sub menu's go into a third submenu. Management would like to keep the menu operating in the same way, but there is no room for expansion and right...
0
810
by: grazzy.cool | last post by:
"Change your language and you change your thoughts." Learn English and free download Grammar & dictionary. Just click the website and share ur thoughts…. "Language shapes the way we think, and determines what we can think about." http://Onlinespokenenglish.googlepages.com/home
0
8297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8717
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8498
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.