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).
Organised syntax (7.1.4)
The specification lists these conventions for well-organised HTML:
- element names, attribute names and values in lower case:
<p class="intro">not<P CLASS="Intro"> - indent nested elements, so the structure is visible
- put attribute values in double quotes
- omit the value of Boolean attributes: write
requiredorhidden, notrequired="required"(the attribute being present means true) - no forward slash on void elements:
<br>not<br />
<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)
| Attribute | What it does | Example |
|---|---|---|
| class | Puts 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"` |
| id | A unique name for one element: used by CSS (#id), JavaScript (getElementById) and same-page links (#id) | `id="prices"` |
| style | Inline CSS for that element only | `style="color: red;"` |
| accesskey | A keyboard shortcut that activates or focuses the element | `accesskey="h"` |
| lang | The language of that element's content | `lang="es"` |
| tabindex | Controls 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"` |
| hidden | A 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.50Worked example
Rewrite this line in the organised style the specification describes: `<INPUT TYPE=checkbox NAME="news" CHECKED="checked" />`
- Lower case for the element and attribute names: input, type, name.
- Double quotes round every value: type="checkbox".
- Boolean attribute without a value: checked.
- No forward slash at the end of a void element.
Answer: `<input type="checkbox" name="news" checked>`
Check yourself
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
Sources
- Pearson Edexcel International Advanced Subsidiary/Advanced Level in Information Technology specification (first teaching 2018), Unit 2 Topics 7 to 11
- Pearson qualifications: Edexcel International Advanced Level Information Technology (2018)
Last updated 8 November 2026. Spotted a mistake? Tell us.