Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How do I style JavaScript using CSS?

Hiya, for class I am making a choose your own adventure game using JavaScript. Really simple stuff basically.

I am using document.write() to display things. My question is: How do I style this writing using css? At the moment it is black and Times New Roman and ugly, and I want it to look nice.

Thanks!

3 Answers

Relevance
  • Chris
    Lv 7
    6 years ago
    Favorite Answer

    You shouldn't use document.write(). Instead, set an element's .innerHTML to the text you want to display. That way you can easily style it.

    http://jsfiddle.net/khrismuc/pL0srg1v/ (no game mechanics, just printing text)

  • 6 years ago

    Let’s consider a (currently) theoretical example — say we have a website where we show a series of technical articles. We want to spotlight some of these articles in a nice animated carousel, but what about users that don’t have JavaScript enabled for whatever reason? Thinking back to our unobtrusive JavaScript knowledge, we want the website functionality to still work for these users, but we might want to style the site differently for those users so that their user experience is still pleasant, even without the carousel.

  • 6 years ago

    If you want to design the elements in the page, then the best way to do that is by using the bootstrap framework.

    add the below 2 lines in the head section of your document and you will see all the fonts and other elements automatically gets changed.

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/

    bootstrap/3.3.4/css/bootstrap.min.css">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/

    bootstrap/3.3.4/css

    /bootstrap-theme.min.css">

    You need to be connected to the internet in order to make this work. If you want to execute it offline then u need to download the framework and link it manually.

    For more information click the below link.

    http://getbootstrap.com/getting-started

Still have questions? Get your answers by asking now.