1

Since it is recommended not to use table elements for layout purposes (non-tabular data), because the special formatting applied to those elements may change in the future, is it also not recommended to use CSS properties such as text-align, which was designed to be used on text, for img elements for the same semantic reason?

I have been looking through the w3c specifications and for instance, line-height seems to be designed for text purposes and has plenty of references in the documentation to font size, so would it be appropriate or abusive to use this property on img elements, simply because they are displayed as inline?

I can understand how the W3C idea of a Semantic Web would use CSS to remove styling information from a page, leaving data exclusively in the HTML for content accessibility. But where is the original rationale documentation for CSS, and why wouldn't they use extremely abstract properties like horizontal-align from the get go, instead of unique alignments for each display type (e.g. text-align: center can be used on all display: inline elements such as img elements) ?

4
  • 1
    From what I've seen, CSS defines much formatting (accounting for many, many edge cases) and little semantic, if any. Commented Aug 1, 2012 at 16:22
  • 1
    @BoltClock So basically CSS isn't concerned with semantic usage in the same way that HTML and its elements such as b vs strong are? Commented Aug 1, 2012 at 16:33
  • @AlexW: The big idea is to separate content from presentation. CSS is meant to describe the presentation, not the semantic content. Commented Aug 1, 2012 at 16:46
  • @Mechanicalsnail So if that was the original rationale behind CSS, why would CSS not be extremely simple and abstract starting at CSS1? Commented Aug 1, 2012 at 16:51

2 Answers 2

3

No. CSS is purely presentational. Some of the properties are just poorly named (text-align being a prime example, it is designed to align all inline children).

Sign up to request clarification or add additional context in comments.

4 Comments

It seems that this is the case, but when I thought about it it seems that CSS could be greatly simplified to just vertical-align and horizontal-align for all elements and become very abstract, right?
I looked for documentation that contained the w3c rationale behind CSS, but didn't come up with anything concerning this.
@Alex W: Sure it could, but it'd break old browsers horribly.
The strange this is that both 'text-align' and 'vertical-align' have been in the spec since CSS1.
0

It is perfectly fine, to use text-align in table cells, that just styling the table as you should be doing. If you want to. Just do it in CSS. Do not use align="right".

https://developer.mozilla.org/en/CSS/text-align Says it applies to: block level elements, table cells and inline-blocks. So it is a use that is documented and intended. If you have inline content use this property to style its alignment.

http://www.w3.org/TR/CSS21/text.html#propdef-text-align Also states

This property describes how inline-level content of a block container is aligned.

So it is not just text, but all inline content.

2 Comments

First of all, this is practically a comment. Second, do you have any documentation from a reputable source supporting your position?
Sorry, noticed it a little to late that I hit the wrong box. I will be editing my answer, stay tuned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.