...

View Full Version : html equivalent of max-width css



think123
07-11-2011, 05:26 AM
Hi folks,

I wanna do a max-width thingy, but not with css, but with html, so I can remove the attribute using javascript. Any help?

Thanks!!
Lucas

VIPStephan
07-11-2011, 11:56 AM
Well, even if there would have existed such an HTML attribute (which never has) it would have been removed from the latest standard specification because this is why CSS exists in the first place: separation of presentation and content (http://en.wikipedia.org/wiki/Separation_of_presentation_and_content). Things like a width are purely presentational attributes so this should be done with CSS which is for the looks, not be in the HTML, which is for structuring the content.

Now, solving your issue is pretty easy nevertheless. You add/remove a class attribute with JavaScript and via this class you can apply a certain style. E. g.:


<div class="selector_for_css">content</div>



.selector_for_css {max-width: 100px;}

If you remove that class with JS the max width is removed – and re-added if you add the class to the element.

think123
07-24-2011, 10:41 AM
Nice Idea.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum