473,804 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1895
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.lan g>

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 misunderstandin g here...

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

As it says, the presentational attributes of HTML "transition al" 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
2442
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 left. In a perfect world I would like the top of the first photo to be aligned with the first line of text. Thanks
4
1887
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 css I took some code from a sample web page, but I don't think it's optimal. What I'm trying to achieve is a horizontal rule at the bottom of the page with a text block left aligned on the left and right aligned on the right. So there would be a...
10
8509
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 way of doing the same? Thanks, Carolyn ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms -...
1
3052
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 horizontal alignment of the other two controls. It appears that they are being stretched due to the absence of the others and I'm not sure how to fix it. If I dont hide anything it looks all lined up (each line is a web user control): Label ...
0
1966
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 regarding inline/inline-containers that use the text-align="justify" attribute value. It seems to plain not work at all in my case. I tried many things and I would like to avoid mustering esoteric alignments manually. Here is a snippet of what I'm...
3
12131
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. L
2
2455
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, despite the fact that I have gotten a green light from W3. link to problem page: I didn't see a feature to attach my css code so I pasted sections of the code that dealt with layout and navigation below. Thanking you in advance,
4
2478
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 volunteered his time for a one time improvement. Now, I'm trying to add a new page to our site, and make it look consistent by removing and replacing the text in an existing page. However, in the one page the links at the bottom page are centered...
2
2043
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 the form of table for which I have used CSS. In firefox the fetched are aligned properly but in Internet explorer, the width alignment is messed up. Here is the code I am using main.php <html> <head> <link href="main.css" rel="stylesheet"...
0
9710
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9589
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
10085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9163
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7626
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
6858
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
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
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
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.