All subjects · Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

Organised HTML syntax and global attributes

Edexcel IAL Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

Examiners reward HTML that is consistently organised, and the specification lists the global attributes that can go on any element (spec 7.1.4 and 7.1.5).

Practise this in the app: instant marking and a fix for every mistake. Free, no email needed to start.

Practise this lesson

Organised syntax (7.1.4)

The specification lists these conventions for well-organised HTML:

<ul class="menu">
  <li><a href="index.html">Home</a></li>
  <li><a href="classes.html">Classes</a></li>
</ul>
<input type="email" name="email" required>

Global attributes (7.1.5)

AttributeWhat it doesExample
classPuts the element in a group that CSS and JavaScript can target; many elements can share a class, and one element can have several classes separated by spaces`class="card featured"`
idA unique name for one element: used by CSS (#id), JavaScript (getElementById) and same-page links (#id)`id="prices"`
styleInline CSS for that element only`style="color: red;"`
accesskeyA keyboard shortcut that activates or focuses the element`accesskey="h"`
langThe language of that element's content`lang="es"`
tabindexControls whether and in what order an element receives keyboard focus with the Tab key: 0 adds it to the normal order, -1 makes it focusable only by script, positive numbers force an order (best avoided)`tabindex="0"`
data-*Stores custom data on an element for JavaScript to read through dataset`data-price="4.50"`
hiddenA Boolean attribute: the element is not displayed`hidden`

Global attributes can be used on any HTML element

class or id?

An id must be unique in the page, so use it for one specific element (a form, a heading that a link jumps to, an element JavaScript changes). Use class for anything that appears more than once or shares a style. A data-* attribute is read in JavaScript through dataset, with the part after data- as the name:

// <button id="buy" data-price="4.50" data-item="swim">Buy</button>
const b = document.getElementById("buy");
console.log(b.dataset.item + " costs " + b.dataset.price);

Output:

swim costs 4.50

Worked example

Rewrite this line in the organised style the specification describes: `<INPUT TYPE=checkbox NAME="news" CHECKED="checked" />`

  1. Lower case for the element and attribute names: input, type, name.
  2. Double quotes round every value: type="checkbox".
  3. Boolean attribute without a value: checked.
  4. No forward slash at the end of a void element.

Answer: `<input type="checkbox" name="news" checked>`

Key idea: Lower case, indented nesting, double quotes, Boolean attributes without values, no slash on void elements. Global attributes (class, id, style, accesskey, lang, tabindex, data-*, hidden) work on any element; an id must be unique.

Check yourself

  1. Which line follows the organised syntax conventions in the specification?
    • `<input type="text" name="town" required>`
    • `<INPUT type="text" name="town" required>`
    • `<input type=text name=town required="required" />`
    • `<input type='text' name='town' required/>`
    Show answer

    `<input type="text" name="town" required>`. Lower case, double quotes, a Boolean attribute with no value and no closing slash.

  2. Why should an id value appear only once in a page?
    • Browsers refuse to display a page with a repeated id
    • An id can only be styled once
    • An id identifies one unique element, so links, CSS and getElementById find exactly that element
    • Repeated ids make the page load more slowly
    Show answer

    An id identifies one unique element, so links, CSS and getElementById find exactly that element. An id is a unique identifier. If it is repeated, getElementById returns only the first match and same-page links become ambiguous.

  3. Which global Boolean attribute stops an element being displayed? Type the attribute name.
    Show answer

    hidden. hidden is a Boolean attribute: its presence means the element is not shown.

  4. A custom button made from a div cannot be reached with the Tab key. Which attribute adds it to the normal keyboard focus order?
    • tabindex="-1"
    • accesskey="0"
    • data-tab="0"
    • tabindex="0"
    Show answer

    tabindex="0". tabindex="0" puts the element into the normal tab order; -1 makes it focusable only from script.

  5. What is displayed when this code runs? ```html <div id="c1" data-level="3">Beginner swim</div> ``` ```js const card = document.getElementById("c1"); console.log(card.dataset.level * 2); ```
    Show answer

    6. dataset.level reads the data-level attribute as the string "3"; multiplying converts it to a number, giving 6.

  6. What does the accesskey attribute do?
    Show answer

    It gives the element a keyboard shortcut so the user can activate or jump to it with a key.. accesskey assigns a keyboard shortcut (usually with Alt or a similar modifier) that focuses or activates the element.

  7. One element needs two classes, card and featured. Which is correct?
    • class="card" class="featured"
    • class="card featured"
    • class="card, featured"
    • class="card;featured"
    Show answer

    class="card featured". Several classes go in one class attribute separated by spaces.

Practise with instant feedback

Sources

Last updated 8 November 2026. Spotted a mistake? Tell us.