HTML CSS and JavaScript Basics

HTML structures content, CSS styles it, and JavaScript makes it interactive by manipulating the DOM; CSS specificity resolves conflicting rules and the JavaScript event loop schedules asynchronous callbacks.

Key formulas & points

Skim these first — then read the full notes below.

  • Semantic HTML improves accessibility and SEO
  • Box model: content + padding + border + margin
  • let and const are block-scoped; var is function-scoped

Topic details

Introduction

This topic covers the front-end triad. You build structure with semantic HTML, style with CSS (mastering the box model and specificity), and add behaviour with JavaScript, understanding scoping and how the single-threaded event loop handles asynchrony.

Key relations & formulas

Formulas (Indian textbook notation)

  • DOMaccess:document.getElementById(id)elementnodeDOM access: document.getElementById(id) → element node

Formulas (Indian textbook notation)

  • CSSspecificityranking:inline>ID>class>elementCSS specificity ranking: inline > ID > class > element

Formulas (Indian textbook notation)

  • JavaScripteventloop:callstack+taskqueue+microtasksJavaScript event loop: call stack + task queue + microtasks

Notation and sign conventions

Relation 1 —
DOMaccess:document.getElementByIdDOM access: document.getElementById

Formulas (Indian textbook notation)

  • DOMaccess:document.getElementById(id)elementnodeDOM access: document.getElementById(id) → element node
Write this relation with symbols exactly as in Deitel Web Dev — Standard reference before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 2 —
CSSspecificityranking:inline>ID>class>elementCSS specificity ranking: inline > ID > class > element

Formulas (Indian textbook notation)

  • CSSspecificityranking:inline>ID>class>elementCSS specificity ranking: inline > ID > class > element
Write this relation with symbols exactly as in Deitel Web Dev — Standard reference before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 3 —
JavaScripteventloop:callstack+taskqueue+microtasksJavaScript event loop: call stack + task queue + microtasks

Formulas (Indian textbook notation)

  • JavaScripteventloop:callstack+taskqueue+microtasksJavaScript event loop: call stack + task queue + microtasks
Write this relation with symbols exactly as in Deitel Web Dev — Standard reference before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.

Concept in depth

The browser parses HTML into a DOM tree that CSS styles and JavaScript manipulates. When style rules conflict, specificity decides the winner — inline styles beat IDs, which beat classes, which beat element selectors — so understanding this ranking prevents mysterious styling bugs. The box model explains layout: every element is content wrapped in padding, border and margin, and miscounting these is the classic cause of sizing surprises. JavaScript runs single-threaded, so long-running work would freeze the page; the event loop keeps it responsive by running synchronous code on the call stack and deferring callbacks through the task and microtask queues, with microtasks (promises) taking priority.

Assumptions and validity limits

State assumptions explicitly before using any relation for html css and javascript basics — steady state, uniform properties, linear elastic material, ideal gas, incompressible flow, etc., as applicable.
Wrong assumptions invalidate the entire solution even when the formula is correct. In Web Technologies viva and GATE descriptive questions, listing valid assumptions often earns separate marks.

Step-by-step problem approach

1. Read the question and list given data with SI units (common in Web Technologies papers).
2. Draw a neat labelled diagram where applicable — examiners in Indian universities award diagram marks even when arithmetic slips.
3. Identify which relation from this topic applies to html css and javascript basics.
4. Use equation 1:
DOMaccess:document.getElementByIdDOM access: document.getElementById
.
5. Use equation 2:
CSSspecificityranking:inline>ID>class>elementCSS specificity ranking: inline > ID > class > element
.
6. Substitute values, compute, and verify units and sign (direction).
7. State conclusion in one line — e.g. safe/unsafe, stable/unstable, feasible/infeasible.

Applications & exam relevance

HTML CSS and JavaScript Basics appears in web apps and REST APIs. In Indian it software curricula this topic is tested because it connects theory to front-end and back-end web stack.
GATE and semester exams often combine html css and javascript basics with earlier units — revise prerequisites before attempting mixed problems.
Industry interview panels sometimes ask: "Where did you use html css and javascript basics?" — answer with a lab, mini-project, or plant visit example if possible.

Common mistakes in exams

Students misjudge CSS specificity (thinking later rules always win), confuse the box model’s components, and misunderstand var hoisting versus block-scoped let/const. Expecting asynchronous callbacks to run before synchronous code finishes shows an event-loop misconception.

Quick revision checklist

Before attempting html css and javascript basics problems, confirm you can:
1. Semantic HTML improves accessibility and SEO
2. Box model: content + padding + border + margin
3. let and const are block-scoped; var is function-scoped
Revise the solved examples in Deitel Web Dev — Standard reference and one previous-year GATE or university paper for this unit.

Worked examples

Try the problem first — open the solution when you are ready to check.

CSS specificity conflict

Problem

An element is targeted by an ID rule (color: red) and a class rule (color: blue). Which colour applies?

Solution

Red applies — an ID selector has higher specificity than a class selector, so it wins regardless of source order. Only an inline style or !important would override it.

Conceptual check — HTML CSS and JavaScript Basics

Problem

In a Web Technologies semester or GATE paper you are asked: "State the main assumption, the governing relation, and one practical consequence of html css and javascript basics." What should a complete answer include?

📖 Standard books (India)

  • Deitel Web DevStandard reference

    Read: Syllabus unit

    Referenced in Indian B.Tech syllabus