Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 2.7 — Global Attributes
HTML · Example 2 of 3

hidden, title, lang, dir and contenteditable

The red paragraph has hidden, but the CSS display: block beat the browser's default hidden style. A classic bug.

Global attributes work on every HTML element: id and class name elements, title, lang and dir describe them, hidden, tabindex and contenteditable change behaviour, and data-* stores your own data.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 6 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write a list of three books, each with data-year. Add a script that logs the oldest year.

02

Mark up an English page sentence that contains the Hindi word नमस्ते, and a user comment of unknown language.

03

Make a "Saved!" message that starts hidden, and a script that shows it.

Explain it without notes

01

What's the difference between id and class? When would you use each?

02

What are data-* attributes for, and how do JavaScript and CSS read them?

03

Explain the three kinds of tabindex values and which one to avoid.

04

Why can an element with hidden still be visible?

hidden, title, lang, dir and contenteditable

Preview

Press Run to see the page.

Console

Nothing logged yet.

Expected console output

msg hidden: true none
forced hidden: true block
Direction of the Arabic line: rtl
Editable: true