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

Right aligning text in a table

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
http://murorum.demon.co.uk/engarde/poules.html. The V/M column should be
centred, while the Indicator and HS columns should be right aligned.

Since I was defining column widths within a <colgroup> I thought it would be
cleaner to define the alignment of these columns there too. Is this not
possible, or am I doing something wrong?

--
Colin Walls

Remove the pink meat to mail me
Nov 4 '05 #1
6 1872
On Fri, 4 Nov 2005, Colin Walls wrote:
Everything is fine apart from column alignment for numbers. Have a look at
http://murorum.demon.co.uk/engarde/poules.html.
| Object not found!
| The requested URL was not found on this server.

Oh, perhaps you meant

| http://murorum.demon.co.uk/engarde/poules.html

without the final full stop.
Since I was defining column widths within a <colgroup> I thought it would be
cleaner to define the alignment of these columns there too. Is this not
possible, or am I doing something wrong?


Alignment in <col> works only in Internet Explorer. For CSS-conforming
browsers like Mozilla, you need to define the alignment through
"td+td", "td+td+td", etc. See my example at
http://www.unics.uni-hannover.de/nht...-alphabet.html
http://www.unics.uni-hannover.de/nht...able8.css.text

--
Netscape 3.04 does everything I need, and it's utterly reliable.
Why should I switch? Peter T. Daniels in <news:sci.lang>

Nov 4 '05 #2
Andreas Prilop wrote:
On Fri, 4 Nov 2005, Colin Walls wrote:

Since I was defining column widths within a <colgroup> I thought it would
be cleaner to define the alignment of these columns there too. Is this
not possible, or am I doing something wrong?


Alignment in <col> works only in Internet Explorer. For CSS-conforming
browsers like Mozilla, you need to define the alignment through
"td+td", "td+td+td", etc. See my example at
http://www.unics.uni-hannover.de/nht...-alphabet.html
http://www.unics.uni-hannover.de/nht...able8.css.text


This would be a pain, since the central block can have a variable number of
columns.

I must admit to still being baffled. Looking the the HTML 4.01 documentation
at w3.org implies what I am doing is correct. However, when I convert my
code to 4.01 strict I still don't get the formatting I want.

I think the only way forward is to add alignment to the cells, rather than
put them at the <colgroup> level.

--
Colin Walls

Remove the pink meat to mail me
Nov 5 '05 #3
On Sat, 5 Nov 2005, Colin Walls wrote:
Andreas Prilop wrote:
Alignment in <col> works only in Internet Explorer.

It may produce the desired effect, but it does not conform to the
interworking specification, so it cannot be said to truly "work".

It's unfortunate, but the table cell is not a true descendant of col
nor colgroup, and the limited extent to which the (CSS) specification
says that cells can be influenced by properties applied to col /
colgroup is set out in the spec.
I must admit to still being baffled. Looking the the HTML 4.01
documentation at w3.org implies what I am doing is correct.
I'm not sure which part of the HTML spec you are looking at, but the
right place to find out about CSS is in a CSS spec.

Currently there's a bit of a hiatus, since the original CSS2
specification isn't exactly implemented by browsers, whereas the
CSS2.1 proposal (which still has the status of a working draft,
according to what it says itself) contains not only, on the one hand,
some dumbing-down of the things which were in CSS2 but did not get
widely implemented, but also, on the other hand, some additions which
may or may not be found widely implemented. So, in general, 2.1
should be read with some care and reservation.

However, on this point I think the 2.1 spec can be taken as a usable
basis - see section 17.3:

http://www.w3.org/TR/CSS21/tables.html#q4
However, when I convert my code to 4.01 strict I still don't get the
formatting I want.
I'm not quite sure what you mean by that, but if you mean what I
suspect that you mean, then there may be a misunderstanding here...

See http://www.w3.org/TR/CSS21/cascade.html#q13

As it says, the presentational attributes of HTML "transitional" might
be treated by a client agent as equivalent to some corresponding CSS
rules, but these are supposed to have zero specificity, meaning that
if CSS applies any different value for that property then the CSS
specification will supervene.

So, taking the HTML presentational attributes away should never modify
anything which has been explicitly specified by CSS - provided, of
course, that the client agent is applying the CSS. The HTML
presentational attributes are only (meant to be) applied in situations
where no relevant CSS style rule is applicable, or where CSS isn't
applied at all.

In short: converting from HTML Transitional to HTML Strict isn't in
itself going to solve the problems that you're having with your CSS.

[Don't get me wrong: using HTML Strict *is* a good idea for new
developments - or at least aiming for it while using at worst a few
carefully controlled relics from Transitional for well-reasoned
compatibility purposes, and some here are sure to contradict me on
even that. I'm saying no more than that converting your HTML from
transitional to strict isn't an answer to the problem we're currently
discussing, no matter how good an idea it is for other reasons.]
I think the only way forward is to add alignment to the cells,
rather than put them at the <colgroup> level.


Yes, which is what Andreas already said. Using td+td, td+td+td etc.
as selectors can be a useful trick with sufficiently advanced
browsers, to avoid having to apply a class to every table cell in the
relevant column and thereby cluttering the HTML. Those which don't
implement the td+td notation are meant to ignore it: the results will
be no worse than with a browser which doesn't implement CSS at all, or
has its CSS disabled by the user for their own good reasons.

There may be other ways available, depending on circumstances - for
example, if a certain column always contains a specific kind of
content (let's say <pre> or <blockquote> or something) then a CSS
selector such as "td pre" could be useful, even for browsers which
don't implement the td+td... notation.

regards
Nov 5 '05 #4
Alan J. Flavell wrote:
On Sat, 5 Nov 2005, Colin Walls wrote:
Andreas Prilop wrote:
> Alignment in <col> works only in Internet Explorer.


It may produce the desired effect, but it does not conform to the
interworking specification, so it cannot be said to truly "work".

It's unfortunate, but the table cell is not a true descendant of col
nor colgroup, and the limited extent to which the (CSS) specification
says that cells can be influenced by properties applied to col /
colgroup is set out in the spec.


The syntax really doesn't help where I have multiple tables of variable
width in the same document.

Assume I am running a very small competition, 13 people. I would divide
these into two poules, 1 of 6 and 1 of 7. I want to present the results in
the tabular form I have shown, with the last three columns having
alignments of centre, right and right. The centre block (the one with all
the V's in) will now have either 6 or 7 columns. Both tables need
presenting in the same document (otherwise it gets messy when you want to
create a document per poule for a competition of 200+ people).

How would you go about this?

--
Colin Walls

Remove the pink meat to mail me
Nov 8 '05 #5
On Tue, 8 Nov 2005, Colin Walls wrote:
Assume I am running a very small competition, 13 people. I would
divide these into two poules, 1 of 6 and 1 of 7. I want to present
the results in the tabular form I have shown, with the last three
columns having alignments of centre, right and right. The centre
block (the one with all the V's in) will now have either 6 or 7
columns. Both tables need presenting in the same document (otherwise
it gets messy when you want to create a document per poule for a
competition of 200+ people).
What follows is mere theory. Whether it's practical to deploy on the
web in this form, I wouldn't care to say. MSIE6 seems to harmlessly
ignore the fun, though, so it's "working as designed" for a back-level
browser, which is nice (and not at all the sort of behaviour that one
has come to expect from IE6 !).
How would you go about this?


Well, if we can agree that there is some reasonable maximum
number of central columns, then I would write td+td styles for all
of the possibilities.

If one did nothing more, of course, the styles for the central columns
would leak over into the later columns. So I would write some rules
with higher specificity for those right-hand columns.

There's an initial sketch, based on your original, at
http://ppewww.ph.gla.ac.uk/~flavell/tests/poules.html

(view this in Mozilla, or in Opera 8.5 etc.).

I simply made a copy of the first table, ripping out its last row and
the corresponding column, in order to have something to test. Then I
did the same again. I ignored whether the resulting data makes any
kind of sense, obviously.

The empty column on the right of the central section is coming out
styled like the central section, of course - you could assign it a
class, and style that (or maybe better, you could work with decorative
border styles, instead of faking a border with empty columns).

cheers
Nov 8 '05 #6
On Tue, 8 Nov 2005, Alan J. Flavell wrote:
On Tue, 8 Nov 2005, Colin Walls wrote:

Assume I am running a very small competition, 13 people. I would
divide these into two poules, 1 of 6 and 1 of 7. I want to present
the results in the tabular form I have shown, with the last three
columns having alignments of centre, right and right.


There's an initial sketch, based on your original, at

[snip]

OK, continuing on from the early sketch, towards your original
question. Because of the variable numbers of columns in the middle
part: if we want to style the right-hand columns using td+td...
notation, then we still need *something* to key on, which would show
CSS that the middle section was done.

Based on your original, I've chosen to key it on the empty cell
that you're using at the right hand side of the middle section,
and I've chosen to apply 'class="k"' to that in order to key on it.

The further classes "centre" and "nombre" aren't necessary if we
follow this plan.

So now we can apply styles to td.k, td.k+td, td.k+td+td , and so on,
in order to style the right-hand columns, and the test page for that
is at http://ppewww.ph.gla.ac.uk/~flavell/tests/poules2.html

MSIE6 still behaves like a back-level browser. Which in this case
means it doesn't honour the desired alignments of the right-hand
columns, in the way that Mozilla (Gecko) and Opera do so. Clearly,
you might consider that too serious a fault to want to use this method
for general web use. I only did this as a demonstration of something
that's feasible with >=CSS2 if one wants to.

(As I commented before, I think it would be somewhat better to do the
decoration via CSS, rather than by including columns of empty cells as
is being done here, but that was aside from the main diet here, so I
left that alone for the purposes of the demonstration).

hope that goes some way to addressing your original question.

cheers
Nov 9 '05 #7

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

Similar topics

1
by: Graham Cross | last post by:
Dear All Is there an HTML way of aligning the images on this page http://www.ageconcernleics.com/review03/chairs03.html so that they appear evenly spaced relative to the text column on the...
4
by: erikd | last post by:
I'm trying to set up a standard "footer" on my pages. I just discovered by reading this newsgroup that straight html is no good and I need to learn how to do it using css. So I while I'm learning...
10
by: Carolyn Marenger | last post by:
I think this is an easy one, but I have not been able to find it anywhere. In HTML, I used <center><img src="whatever.gif></center> to horizontally center a graphic on a page. What is the CSS...
1
by: Eric | last post by:
I have a user control (with three controls inside it) that appears multiple times in the containing page. Sometimes I want to hide the rightmost control in the UC but if I do that it screws up the...
0
by: Jean-François Michaud | last post by:
Hello people, I'm having a hard time figuring out how to align my page numbe properly to the right margin in the Table of content I'm generating. I'm using FOP and there are some known issues...
3
by: Leonardo da Vinci | last post by:
Greetings gentlemen and ladies, I have a question: in Tkinter, how to align a Listbox entry (i.e. a line of text) to the right? Google did not show up the answer to my request. Thanks very much....
2
by: agbee1 | last post by:
Hello: I've finally made the effort to ween myself from overly using tables and use CSS for my positioning. However, I am having a problem with my navigational menu properly aligning in Firefox,...
4
by: Corey Walker | last post by:
Hello: I am a webmaster for a non-profit organization. I do know some HTML, but I'm by no means an expert. Recently, many pages on our site were redesigned by a professional web designer, who...
2
by: gubbachchi | last post by:
Hi all, I have a problem with css table. The code below works fine with firefox but the problem is with Internet explorer. This code actually fetches data from mysql database and display it in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.