Forum Moderators: not2easy
text-align, as said, only works on the parent element (to align the child)
Applying text-align:right to an <hx> tag SHOULD right-align the header text, as long as nothing else is affecting the tag.
The text-align attribute centers children of a block level element, but I believe the text within that element actually counts as a child node of the element itself (in the DOM). Meaning text-align applies to the text in the element, as well as any other inline elements contained in the block.
if u want the h2 to be 'aligned' to the right, just use float:right
Using float to align something to the right will work, but it's a bit of an overkill. In order to avoid other pitfalls that will come along with it, you also have to apply a clear:right to the element following that header. This can completely kill a float-based layout in some browsers, especially if that floated-header-cleared-paragraph chunk is located inside of a floated container.
Of course, if you're layout doesn't use other floats, you'll be fine.
I suspect something else in your CSS is affecting the style of that header tag.
i now use for some time a floatbased design, 3 columns, header, footer, and i can easily float WITHIN a container... floatclearing SHOULD only happen within the same container... (i believe ie/mac or ie5/win or something doesnt work that way...)
(and then there's the :after css thing, to clear an element (with a little help to fix it for IE)
and i can easily float WITHIN a container
floatclearing SHOULD only happen within the same container
Of course this doesn't always happen (it's not supposed to happen at all!), and if I'm remembering correctly it's a browser specific problem (probably IE/Mac).
Anyway PAUL, here's a quote from the w3 specs on text-align [w3.org]:
This property describes how inline content of a block is aligned.
Obviously something else in your code is snarling up that <h2>.