No announcement yet.

HTML: Choosing more than one CSS on the fly, possible?

  • Filter
  • Time
  • Show
Clear All
new posts

  • HTML: Choosing more than one CSS on the fly, possible?

    Hi all.

    I'm ok with writing up basic html files I think. I just use notepad. I'm also comfy using css to make the html files pretty etc. Now the question I've got is thus: Is it possible to have a button/option/script on your html page that allows you to alter which css file your html page uses to get its defaults.

    I want to be able to alter html pages based upon the device they're viewed upon. Either automatically (iphone vs full webpage view kinda thing) or manually by the user (select your device in a portal page before viewing the site)

    In a nutshell I just need to have a couple of width:???px} adjustable in a css. I don't want any lateral scrolling in the browser experience.

    Is this possible or am I dreaming?

    This isn't a corporate thing, or even a money maker. I'm just fucking around putting an idea into place. If I can't do this I'm going to shitcan the idea completely.
    Work Buy Consume Die

  • #3
    This css Zen Garden: The Beauty in CSS Design is also a good site on making a whole page appear different through the use of nothing but CSS. Not automatic based on browser, but lets the user choose..

    More on the page Nath posted:
    How to Allow Your Visitors to Switch Between Alternate CSS Styles / Themes (
    How to Use JavaScript to Change a Cascading Style Sheet (CSS) Dynamically (
    Last edited by Visitor; 14-04-2011, 06:10 PM.
    Tomorrow: A mystical land where 99% of all human productivity, motivation, and achievement is stored.

    Avatar used with permission from Mekon


    • #4
      Fantastic gents, I appreciate that.

      I also read up on some javascript tools that can help me do this too. Now I just have to decide what redeeming features having all these css files will be.

      I was thinking for nightmode/daymode colour themes (I'm a huge fan of red text on black background to preserve night vision), and also per device page width formatting, but after I explored a little, the page width is largely irrelevant for the site I'm making, so I'm probably only needing colour scheme changing.
      Work Buy Consume Die


      • #5
        Worth having a look at jQuery if you want to fuck with things on the fly too - it takes a bit of a mental sidestep to get into the swing of it, but once you're there most browser cross compatibility issues disappear and things get very, very easy to do when you're bashing away at the DOM and styles.
        "Once upon a time we would obey in public, but in private we would be cynical; today, we announce cynicism, but in private we obey."