Hi again. Just wondering what is the simplest and best way to center html text within a coloured html box.
Tried padding each side a similar amount. looks good but not when previewed. What’s up here? What is the correct procedure please? It is a bit hit and miss for me on this one. obviously a gif would work. Is that the best way?
Hi again. Just wondering what is the simplest and best way to center html text within a coloured html box.
Tried padding each side a similar amount. looks good but not when previewed. What’s up here? What is the correct procedure please? It is a bit hit and miss for me on this one. obviously a gif would work. Is that the best way?
Sorry - I mean centre in the horizontal way, equidistant from top and bottom
simply draw a colored html box say 30 px high
pad 12px each side
fill with html text arial 12 pt 12pt in the style
looks centered now right?
preview - kaput! text moves up slightly
Sometime around 1/4/08 (at 07:39 -0400) John-Paul Kernot said:
Thanks Paul - must be something else wrong here. I am looking into it.
You are right, however, about the need for a truly simple way to do
this. (BTW, it is probably more helpful to talk about “vertical
centering” rather than just centering; that’s easily done with a
simple paragraph alignment style.)
Vertical centering is a very useful thing in traditional DTP tools.
It is possible in table cells; those have a vertical alignment
setting that can be applied. But I don’t know if there’s an
equivalent in CSS for divs. The process of using padding is okay, ish.
The apparent vertical centering effect breaks if the text that’s been
carefully centered happens to run over one more line, or underruns by
a line too for that matter. This is bad enough with text that might
happen to be drawn slightly larger in some browsers, but if you want
to achieve this effect and you’re working with CMS-based content -
just forget it. That fairly basic print-design feature seems to be
damn well non-existent in CSS-based web design.*
I’m not talking about just Freeway here BTW, this seems to be a real
weak spot of CSS in general, regardless of what tool you use to
write/generate it.
(*I will of course be delighted to be proved wrong!)
Simple? Well, it’s not terribly difficult but then there’s no point-n-click solution either. Take what you can get I suppose. I’ve used this in the past though there are several variations out there, all of which have limitations from what I’ve found so far. Depending on if you want to center just one line or an entire block the method may vary. Hopefully the CSS 3 spec will offer better support.
Sometime around 1/4/08 (at 09:57 -0500) Todd said:
Simple? Well, it’s not terribly difficult but then there’s no
point-n-click solution either. Take what you can get I suppose. I’ve
used this in the past though there are several variations out there,
all of which have limitations from what I’ve found so far
Exactly. If I want to have something centered but that thing could
have a varying number of lines, because it is content pulled in from
some external source (i.e. some database-driven source such as a blog
or regular CMS) it is simply not practical to attempt.
Hopefully CS3, as you say. But how many years will it be before we
can rely on the average visitor having a CS3-spec browser?
I agree. I threw this example out there to show that it is possible
to do without using padding using the current CSS2 spec albeit with
certain restrictions depending on your requirements. It may not FW-
simple but it is another possible option.
Todd
On Apr 1, 2008, at 10:40 AM, Keith Martin wrote:
Sometime around 1/4/08 (at 09:57 -0500) Todd said:
Simple? Well, it’s not terribly difficult but then there’s no
point-n-click solution either. Take what you can get I suppose. I’ve
used this in the past though there are several variations out there,
all of which have limitations from what I’ve found so far
Hopefully CS3, as you say. But how many years will it be before we
can rely on the average visitor having a CS3-spec browser?