
Using data-* Attributes and dataset in JavaScript
Use data attributes and dataset in JavaScript to connect HTML and behaviour cleanly, handle camelCase mapping, event delegation, and string values.
Articles
The guides are the practical part of this archive: working explanations for a specific web development problem, written to show the decision as well as the answer. The subject varies, but the aim is consistent: enough context to use the technique sensibly rather than copy it blindly.

data-* Attributes and dataset in JavaScriptUse data attributes and dataset in JavaScript to connect HTML and behaviour cleanly, handle camelCase mapping, event delegation, and string values.

classList in JavaScript: add(), remove(), toggle(), and contains()Use classList in JavaScript for add(), remove(), toggle(), and contains(), with cleaner DOM state updates, validation examples, and className cautions.

DOMContentLoaded vs. load in JavaScriptCompare DOMContentLoaded and load in JavaScript, including parsing, asset loading, script timing, selector failures, and when each event is useful.

querySelector Returns null in JavaScriptDebug querySelector returning null in JavaScript by checking selector syntax, DOM timing, missing elements, search scope, and querySelectorAll differences.

Use links for navigation and buttons for actions, preserving native focus and keyboard behaviour before adding custom click handlers or ARIA roles.

Choose between textContent and innerHTML safely, handle Internet Explorer's innerText fallback, and know exactly when untrusted HTML needs sanitisation.

removeEventListener() Needs the Same Function ReferenceUnderstand why removeEventListener needs the original callback reference, how anonymous functions differ, and what Internet Explorer required in 2010.