Front End Help

Interactions Pattern

Interactions are forms. The styles for forms and form elements are found in 07-interactions.css.

Interactions is an abstract supertype. That means you won’t find an interactions class in our code. Instead, “interactions” is synonymous with the form element. So if we wanted all interactions to have a gray background, we would use form { background: #ccc; }.

Rules

Unless a form is very simple, it should be broken down into logical sections using <fieldset>. For example, the Work Search form is grouped into Work Info, Work Tags, Work Stats, and Search.

Each <fieldset> should be labeled with a <legend>. Some screen readers don’t read form legends. For them, we repeat the legend text as a landmark heading, e.g. <h3 class="landmark heading">. If the legend text is more than a few words long, the form probably needs rearranging.

Inputs should be labeled. Most of the time, this means using <label>, but in some very simple or very complex forms (e.g. form tables on wrangling pages), it means using the title attribute on the <input> itself. A label should come before a text field (<input type="text"> or <textarea>) or select menu (<select>) but after a radio button (<input type="radio">) or checkbox (<input type="checkbox">). A label may also surround a checkbox or radio button.

Form labels and controls are inline elements, which means they have to be wrapped in block level elements. We generally use definition lists (<dl>) because the term (<dt>) and definition (<dd>) structure corresponds nicely to the typical <label>Label</label> and <input> structure of a form. However, if a form cannot be logically structured as terms and definitions, it can be structured as paragraphs.

Submit buttons are a type of control, so they also need to be wrapped in block level elements. Most forms only have one submit button – they can use <p class="submit">. Forms with many submit buttons (e.g. the work form) can use <ul class="actions">.

XHTML diagram

The following diagram is adapted from the new work form.

  1. <form class="verbose post">
    1. <p class="required notice">* Required information</p>
    2. <fieldset>
      1. <legend>Tags</legend>
      2. <h3 class="landmark heading">Tags</h3>
      3. <p class="note">Tags are comma separated, 100 characters per tag.</p>
      4. <dl>
        1. <dt class="required">
          1. <label>Rating*</label>
        2. <dd class="required">
          1. <select>
            1. <option>Not Rated</option>
            2. <option...
        3. <dt class="required">
          1. <label>Archive Warning*</label>
        4. <dd class="required">
          1. <fieldset>
            1. <ul>
              1. <li> <input type="checkbox"> <label>Choose Not To Use Archive Warnings</label>
              2. <li...
        5. <dt class="required">
          1. <label>Fandoms*</label>
        6. <dd class="required">
          1. <input type="text">
          2. <p class="footnote">This is information about the field.</p>
    3. <fieldset>
      1. <legend...
      2. <h3 class="landmark heading"...
      3. <dl>
        1. <dt...
        2. <dd...
    4. <fieldset>
      1. <legend>Post</legend>
      2. <h3 class="landmark heading">Post</h3>
      3. <ul class="actions">
        1. <li>
          1. <input type="submit">
        2. <li...