473,396 Members | 1,998 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,396 software developers and data experts.

Use CSS to specify table column styles?

I have an HTML table with two columns of text. Here's what it looks like:

FIRST COLUMN (each cell is ID="date')
Background orange, font Serif size 13px, aligned center
SECOND COLUMN (each cell is class="entry")
Background white with clickable text link (Sans-serif 11px, link black,
visited blue, hover navyblue)

The first column's content has been assigned CSS ID "date", in the above
mentioned style. The second column's content has been assigned CSS class
"entry" (hoverable text link), in the above mentioned style. I'm frequently
updating the table with more rows.

Doing it this way, I have to label the corresponding TD's "date" and "entry"
for *each* row. Considering each column has its own style, is there a way to
tell CSS to specify that?

Any help is appreciated. Thanks!
Sep 10 '05 #1
3 3215
Els
Yeah wrote:
I have an HTML table with two columns of text. Here's what it looks like:

FIRST COLUMN (each cell is ID="date')
That's wrong already then: each ID can only be used once per document.
Use class="date" instead.
Background orange, font Serif size 13px, aligned center
font-sizes are better in percentages
SECOND COLUMN (each cell is class="entry")
Background white with clickable text link (Sans-serif 11px, link black,
visited blue, hover navyblue)

The first column's content has been assigned CSS ID "date", in the above
mentioned style. The second column's content has been assigned CSS class
"entry" (hoverable text link), in the above mentioned style. I'm frequently
updating the table with more rows.

Doing it this way, I have to label the corresponding TD's "date" and "entry"
for *each* row. Considering each column has its own style, is there a way to
tell CSS to specify that?
Some styles in some browsers work by adding styles to colgroups, but
it's certainly not a cross-browser solution. The best way is indeed
using the classes on each TD.
Any help is appreciated. Thanks!


You're welcome.

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: Legião Urbana - Hoje A Noite Não Tem Luar
Sep 10 '05 #2
Yeah a écrit :
I have an HTML table with two columns of text. Here's what it looks like:

FIRST COLUMN (each cell is ID="date')
This is an error; you can't do that in a conformant document.
Background orange, font Serif size 13px, aligned center
CSS 2.1 border, background, width and visibility properties can be
applied to <col>; the other CSS properties can not be applied to <col>.
http://www.w3.org/TR/CSS21/tables.html#q4

And as mentioned by Els, font-size is best used with em or %:
W3C QA Assurance tip for webmasters:
Best recommended practices: Good usage of CSS's font properties
"Do not specify the font-size in pt, or other absolute length units.
They render inconsistently across platforms and can't be resized by the
User Agent (e.g browser).
Use relative length units such as percent or (better) em"
http://www.w3.org/QA/Tips/font-size#goodpractice

SECOND COLUMN (each cell is class="entry")
Background white with clickable text link (Sans-serif 11px, link black,
visited blue, hover navyblue)

The first column's content has been assigned CSS ID "date"


id attribute value must be a document-unique attribute value.

Gérard
--
remove blah to email me
Sep 10 '05 #3
Yeah wrote:
I have an HTML table with two columns of text. [...]

Doing it this way, I have to label the corresponding TD's "date" and "entry"
for *each* row. Considering each column has its own style, is there a way to
tell CSS to specify that?

The "adjacent sibling combinator" (+) does what you are asking.
#style1 td { ... } /* Style for all columns */
#style1 td + td { ... } /* Style for second column. */

Unfortunately it is not supported by IE.

Instead of having a class (not an ID!) for each column, create a style
for all columns and an overriding class for one of the columns.

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Sep 10 '05 #4

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

Similar topics

14
by: James A. Donald | last post by:
-- I am just beginning to get into CSS. I like to keep all my html simple and generic looking. I want to use a table, because I have, (gasp) tabular data. I want it to look like a table. Not...
1
by: MQ | last post by:
I have been trying to insert a col tag using DOM but I can't seem to make it work. In the following script I create a table with rows and columsn. I tried to modify the column style, but doesn't...
6
by: Colin Walls | last post by:
I am writing some HTML and CSS that will eventually be produced by a program for running fencing tournaments. Everything is fine apart from column alignment for numbers. Have a look at...
3
by: Darryn Ross | last post by:
Hi, I am having a few problems with my datagrid, the data in my database isn't coming through right. for example 100.00 in the table is coming through as 100 and 01/01/2004 in the table is...
6
by: scorpion53061 | last post by:
I cannot figure out the equation of how this would work to automate MS Word table style. This is the vba converted but it says that style is not a member any ideas anyone? With...
2
by: Jeff | last post by:
I've been trying for days to figure out why the spacing between the rows on the left-most column of my table is screwy. Take a look here: http://mypage.iu.edu/~jbeverid/index_new.htm Right...
1
Death Slaught
by: Death Slaught | last post by:
I will be showing you how to make a very simple but effective three column layout. First we will begin with the HTML, or structure, of our three column layout. <!DOCTYPE html PUBLIC...
1
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons:...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.