Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2011
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts

    html equivalent of max-width css

    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

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,695
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    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. 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.:
    Code:
    <div class="selector_for_css">content</div>
    Code:
    .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.

  • Users who have thanked VIPStephan for this post:

    think123 (07-24-2011)

  • #3
    New Coder
    Join Date
    Jun 2011
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Nice Idea.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •