/    Sign up×
Community /Pin to ProfileBookmark

Right alignment in <td> elements

According to this reference

[QUOTE]

[url]http://www.w3.org/TR/html401/index/attributes.html[/url]

[/QUOTE]

The “align’ keyword is still part of 4.01 and is associated with the “td” element. I am using a 4.01 strict doctype, and the align=’right’ is not right aligning my cells at all. As a matter of fact I am finding it very difficult to set any kind of class that will. The only thing that is getting the job done is on each iteration of output to specify it in the output as a style attribute in css manner like:

[CODE]
<td style=”text-align:right”>12.75</td>
//or
<td style=”text-align:right”><?php $Amt ?></td>
[/CODE]

That’s pretty unwieldy, when according to the reference this should work, but doesn’t:

[CODE]
<colgroup>
<col width=”145″>
<col width=”70″ align=”right”>
<col width=”70″ align=”right”>
</colgroup>
[/CODE]

Am I reading something wrong?

to post a comment
HTML

2 Comments(s)

Copy linkTweet thisAlerts:
@BeachSideJul 02.2005 — so your saying that this is not working?
[code=html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.tdRight {
text-align: right;
}
-->
</style>
</head>

<body>

<table>
<tr>
<td class="tdRight">12.75</td>
</tr>
<tr>
<td class="tdRight"><?php $Amt ?></td>
</tr>
</table>
</body>
</html>

[/code]
Copy linkTweet thisAlerts:
@JayhawkauthorJul 02.2005 — Correct, putting it as a member of the class has not worked.

Well, a caveat on that.

I tend to build my style sheets smorgasboard style: like a set of classes for colors, one for fonts, another for alignments, etc. Then when I specify the class for the element I combine more than one of these definitions to get the element specification I want. All pretty standard stuff. But when I class the <td> as
[CODE]
<td class="this that tdRight">
[/CODE]

then no, the "this" and "that" are applied but it does nor right align. I haven't tried it with the text-align as one element in a class fully defined for a single-word call, since it goes against my grain to build that many classes (you's need one for each type of <td> in the table). But maybe I'll try it.
×

Success!

Help @Jayhawk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...