This page is powered by a single stylesheet which turns ordinary HTML into a Choose Your Own Adventure-like gamebook, and another that describes its colors. No JavaScript is involved, and the HTML is kept nearly undisturbed.

How to Use It

To use choice.css you'll need to be at least a little familiar with CSS and HTML.

(If you're not comfortable with HTML, consider trying Twine instead. It's got a graphical interface and a simpler markup format. It's also a good choice if you want to do something more complicated than CYOA.)

Writing Your HTML

The first thing you need is a bare HTML page, including choice.css as a stylesheet. (You can also include it inline between a <style>...</style> block.)

<!DOCTYPE html>
<html>
  <head>
    <link rel=stylesheet href=choice.css>
    <title>...</title>
  </head>
  <body>
    <main>
          ...
    </main>
  </body>
</body>

Inside the main block, place a series of <section> elements with your writing, and give them each an id:

<section id=example>
  This is an example section.
</section>

Then inside each section, you can create links to the other sections with standard HTML links:

<section id=other-example>
  This is a <a href='#example'>link to that section</a>.
</section>

Transitions

The three different transition styles you'll see on this page (horizontal pop-in, vertical pop-in, and fade) will be applied automatically to create some variety in transitions.

If you'd like more manual control, you can use the vpop, hpop, and fade classes on your sections, or write your own using standard CSS transitions.

Styling

You can style the rest of the page using CSS normally, as long as you keep the main display structure from choice.css — the absolutely-positioned, overflow-hiding <main> element, and the selectors for <section> elements.

You can also add more elements. For example, this page adds a header with some navigation links. And while JavaScript isn't required, you can include JavaScript code in your page for more advanced effects.

Errors

If you link to a section that doesn't exist, or the reader types one in manually, you'll see the last section in the page even if you didn't give it an ID. You might want to write your last section with this in mind.

Why Bother?

Because...

Why Not?

License

choice.css and this demonstration page are released into the public domain, or as close as possible in your jurisdiction. We waive all our rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.

You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

However, we would appreciate it if you kept a link to this page in the file when you use it, to help inform other people about what it does and how they can use it too.

If the target location is invalid, the last section — this section — is displayed, even if it doesn't have an ID. You can put any link you want here, like back to the first section, or just plain back.

It'd be nicer if the default was the first section, or a special section, but that's not currently possible in CSS. At times CSS Selectors Level 4 has included features that would help with this, but they don't work in any browser yet.

Or, you could write your page so that the last section is the first one people should read. But that will mess up the order when printing or reading the page without the special stylesheet. And it's just confusing.