Text alignment - CSS or HTML?
I'm wondering what'开发者_如何学Gos the best way to do an alignement ?
Using CSS with the property : text-align
or using HTML with align=""
Thanks !
http://www.w3.org/TR/html4/present/graphics.html says it's even deprecated to use align.
I'm of the opinion to do everything for design/layout in CSS. Keep your HTML for structure and let your design stay in the CSS. Both do the same thing but the CSS approach is neater (in my opinion anyway).
As mentioned by Marnix, it's deprecated in HTML4. It's not even supported in HTML5 so if you're structuring your HTML that way, you only have one choice.
As a rule for things I do:
Design:: Keep everything in external CSS files
Client Side Scripts: Keep everything in external JavaScript files
Content/Structure: This is what the HTML is for (I suppose we have to leave something in there)
CSS should be the way you do it really. Using inline styles usually creates more work for you in the long run.
giving it a class and specifying it in the css as text-align: right for instance is the best way according to me. With align="" you know the obvious problem of repeating....hope this helps
Use CSS if you will have several elements of a same kind in your page. Then give them a class and build a rule for that class.
CSS is there for helping you factoring your rules and avoiding assigning a style manually to every single element.
精彩评论