Programming & Web Development
JavaScript and interactive web pages
Making a web page respond to clicks and typing: variables, functions, the page structure (the DOM), events and forms.
Suits: Students who know basic HTML and CSS
Duration, fees and batch timings are quoted by the head office or your centre.

2 study books in this course
- HTML and CSS
- JavaScript for Interactive Web Pages
- Lessons
- 17
- Practice questions
- 75
- Free ebooks
- 0
About the course
What the JavaScript course is about
HTML gives a page its content and CSS its look; JavaScript makes it respond. This course takes a student who has built a simple page and adds behaviour: buttons that do something, forms that check themselves and content that changes without reloading.
It covers the language itself, variables, conditions, loops, functions, arrays and objects, then the DOM and events, and ends with a small quiz or to-do page. The HTML and CSS study book is part of the course for revision.
What you will practise
Drawn from the lessons of the study books below.
- 01
Declare variables and use operators, conditions and loops
- 02
Write and call functions
- 03
Work with arrays and objects
- 04
Select and change page elements through the DOM
- 05
Respond to clicks and typing with events
- 06
Check a form before it is sent and find mistakes with the browser console
What you will learn
2 subjects, 17 lessons
Every lesson of the study books that come with this course in the student portal, with the key points of each lesson and exercises to try. Your centre gives you the syllabus, the duration and the fee.
Subject 1 of 2
HTML and CSS
Build web pages with HTML5 and style them with CSS3, from document structure, text, tables and forms to selectors, the box model, Flexbox, Grid and responsive design.
1The structure of an HTML5 document4 min read · 5 key points · 3 exercises
Key points
- HTML is a markup language that labels the structure of content; it is not a programming language.
- An element is usually an opening tag, content and a closing tag; attributes go in the opening tag as name="value".
- Every page starts with <!DOCTYPE html> and has one html element containing a head and a body.
- The head holds information about the page, such as charset, viewport and title; the body holds the visible content.
- Void elements such as br, img, input and meta have no closing tag.
Try this
- Open Notepad, type the HTML5 skeleton with the doctype, html (lang set to en), head and body elements, set the title to My First Page, save it as index.html in a new folder named website with All files as the save type and UTF-8 encoding, and open it in Chrome or Edge to check that the title shows on the browser tab.
- In the same page, add an h1 heading with your name, two paragraphs about your favourite subject, an hr line between them, a br line break inside one paragraph and a comment that marks where the second paragraph starts; reload the page and confirm that the comment is not displayed.
- Add a sentence containing the rupee sign ₹ and a few words in Hindi and check that they display correctly, then right-click any web page, choose View page source and write down five element names and two attributes you recognise.
2Headings, paragraphs, lists, links and images4 min read · 4 key points · 3 exercises
Key points
- Use one h1 for the page title and go down the heading levels in order, without skipping.
- ul makes a bulleted list and ol a numbered list; every item is an li.
- The a element creates links; href can be an absolute URL, a relative path, a #id on the same page, mailto: or tel:.
- Every img needs alt text that describes it, or alt="" if it is purely decorative.
Try this
- Build a page about your town with one h1, three h2 sections and an h3 under one of them, write a paragraph in each section, use strong for one important warning and em for one stressed word, and put a postal address on three lines using br.
- Add an unordered list of five things to carry to an exam, an ordered list of the steps to make tea with a nested list under one step, and change the ordered list to Roman numerals with its type attribute; then create contact.html and link the two pages to each other with relative links.
- Save a photo in an images folder, show it with an img element that has descriptive alt text, width and height, then misspell the file name to see the alt text appear in place of the image; also add a link that jumps to a section by its id, an email link using mailto: and a phone link using tel:.
3Tables and forms3 min read · 5 key points · 3 exercises
Key points
- Use tables only for tabular data: tr makes a row, th a header cell and td a data cell.
- colspan joins cells across columns and rowspan joins cells down rows.
- Link every input to a label by matching the label's for attribute to the input's id.
- method="get" puts form data in the URL; method="post" sends it in the request body, which suits passwords.
- Radio buttons with the same name allow one choice; checkboxes allow several.
Try this
- Make a marksheet table for five students with a caption, a thead row of Roll No, Name, Hindi, English, Maths and Total headings, a tbody with their marks, and a tfoot row in which the words Class average span the first two columns using colspan.
- Create your weekly class timetable as a table with the periods down the first column and the days across the top, use rowspan to show a two-period practical as one tall cell and colspan to show the lunch break as one cell across all the days.
- Build an admission enquiry form with a label for every control: text inputs for name and email, a tel input for phone, a date input for date of birth, radio buttons for morning or evening batch inside a fieldset with a legend, checkboxes for three subjects, a select for the city, a textarea and a submit button; make the name required, try submitting it empty, then leave out the action attribute so that the form sends its data back to the same page, set method to get, submit it filled in and read the name=value pairs added to the address bar.
4Semantic HTML5 elements3 min read · 5 key points · 3 exercises
Key points
- Semantic elements describe what content is, which helps screen readers, search engines and other developers.
- header, nav, main, article, section, aside and footer name the common parts of a page.
- Use one visible main per page for the content unique to that page.
- article is for self-contained content; section groups related content under a heading.
- div and span carry no meaning and are used when no semantic element fits.
Try this
- Write a page for an imaginary electronics shop using header, nav with three links, main, two article elements for two products, an aside with a buying tip and a footer with the address, without using a single div.
- Write a short page built only from div elements with classes such as menu, content, sidebar and bottom, then replace each div with the matching semantic element and check that there is exactly one main and that it is not inside header, footer, nav, article or aside.
- Give one article its own header with the product name and a footer with the date it was added, place a figure with an image and a figcaption inside it, add a section with its own h2 that groups both products, and write a comment beside each article, section and aside explaining why you chose that element.
5CSS basics: selectors, colours and fonts3 min read · 5 key points · 3 exercises
Key points
- A CSS rule is a selector followed by declarations of the form property: value;
- Use an external stylesheet linked from the head for real websites.
- Class selectors start with a dot and can be reused; ID selectors start with # and must be unique.
- When rules conflict, !important wins, then higher specificity, then the rule written later.
- Colours can be named, hex, rgb() or hsl(); font-family lists fallbacks ending in a generic family.
Try this
- Create style.css, link it from the head of index.html with a link element, set the body font-family to "Noto Sans", Arial, sans-serif with a font-size of 1rem and a line-height of 1.6, then colour the h1 with a named colour, a hex code and an rgb() value in turn.
- Give two paragraphs the class price and one heading the id offer, style them with .price and #offer selectors, add a nav a rule and an a:hover rule that changes the link colour, and style h1 and h2 together with one grouped selector.
- Write two rules that give the same paragraph different colours, one using the element selector p and one using a class selector, predict which colour wins and check in the browser; then swap the order of the rules, and finally add !important to the element rule and note the result each time.
6The box model and Flexbox3 min read · 5 key points · 3 exercises
Key points
- Every element is a box of content, padding, border and margin.
- With the default content-box, width covers only the content; border-box includes padding and border.
- Margin and padding shorthand runs clockwise: top, right, bottom, left.
- display: flex on a container lines up its children along one axis.
- justify-content works on the main axis and align-items on the cross axis.
Try this
- Style a .card with width 300px, padding 20px, a 5px solid border and margin 16px, check in the browser developer tools (F12) that it takes 350px of width, then add box-sizing: border-box and confirm that it becomes exactly 300px wide.
- Give four boxes margins written with one, two and four values and label each box with the values you used, centre a box that has a fixed width with margin: 0 auto, and place a paragraph with a 20px bottom margin above one with a 30px top margin to see that the gap is 30px, not 50px.
- Build a navigation bar with display: flex containing a logo, four links and a search box, use justify-content: space-between, align-items: center and gap: 12px, give the search box flex: 1, add flex-wrap: wrap and narrow the window to watch the items wrap onto a new line.
7CSS Grid and responsive design3 min read · 5 key points · 3 exercises
Key points
- Grid lays out rows and columns together; Flexbox handles one direction at a time.
- repeat(3, 1fr) makes three equal columns; fr is a share of the free space.
- grid-column: span 2 makes an item two columns wide.
- Responsive pages need the viewport meta tag, flexible sizes and media queries.
- Mobile-first means base styles for phones, then min-width media queries for larger screens.
Try this
- Lay out six product cards with display: grid, grid-template-columns: repeat(3, 1fr) and a 16px gap, make the first card span two columns with grid-column: span 2, then change the columns to 2fr 1fr 1fr and see how the space is shared.
- Build a gallery of nine photos with grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)), add the rule img { max-width: 100%; height: auto; }, and drag the browser window from wide to narrow, counting how many columns fit at each width.
- Write a mobile-first product page that shows one column by default, two columns from a min-width of 600px and four from 1024px, check that the viewport meta tag is in the head, then open device emulation with F12 and Ctrl+Shift+M and test it at 390px for sideways scrolling, readable text and buttons large enough to tap.
Glossary: 25 key terms of HTML and CSS
- Alt text
- A short description of an image, written in the img element's alt attribute, that screen readers read aloud and browsers show if the image fails to load.
- Attribute
- Extra information written in an opening tag as name="value", such as the href of a link or the src of an image.
- Box model
- The way a browser draws every element as a rectangular box made of content, padding, border and margin, from the inside out.
- Cascade
- The rules CSS uses to decide which declaration wins when several set the same property on an element: importance first, then specificity, then the order the rules are written in.
- Class selector
- A CSS selector that starts with a dot, such as .price, and styles every element whose class attribute contains that name.
- CSS
- Cascading Style Sheets, the language that controls how HTML looks, including colours, fonts, spacing and layout.
- CSS Grid
- A CSS layout method, switched on with display: grid, that places items in rows and columns at the same time.
- Doctype
- The declaration on the first line of an HTML file that tells the browser the page is HTML5, so that it displays it in standards mode.
- Element
- One part of an HTML page, usually made of an opening tag, its content and a closing tag, such as a paragraph or a heading.
- Flexbox
- A CSS layout method, switched on with display: flex on a container, that lines up its direct children along one direction, as a row or a column, letting them wrap onto new lines when flex-wrap is set.
- fr unit
- A CSS Grid unit meaning one fraction of the free space, so 2fr 1fr makes the first column twice as wide as the second.
- HTML
- HyperText Markup Language, the markup language that labels the structure of a web page, such as its headings, paragraphs, links and images.
- ID selector
- A CSS selector that starts with #, such as #cart, and styles the one element whose id attribute has that name, which must be unique on the page.
- Label
- A form element tied to an input by matching its for attribute to the input's id, so that clicking it focuses the input and screen readers announce it.
- Margin
- The transparent space outside an element's border that pushes neighbouring elements away.
- Media query
- A block of CSS written with @media whose rules apply only when a condition is true, such as the browser window (the viewport) being at least 600px wide.
- Mobile-first
- A way of writing CSS in which the base styles suit phones and min-width media queries add layout for wider screens.
- Padding
- The space inside an element's box between its content and its border, which is filled by the element's background colour.
- Pseudo-class
- A selector part written after a colon that targets an element in a particular state, such as a:hover or input:focus.
- Responsive design
- Designing a page so that its layout adapts to every screen size, using the viewport meta tag, flexible sizes and media queries.
- Selector
- The part of a CSS rule that chooses which HTML elements the rule's declarations apply to.
- Semantic element
- An HTML element whose name describes the meaning of its content, such as header, nav, main, article or footer.
- Specificity
- The weight of a CSS selector, used to decide which of two conflicting declarations wins when neither is marked !important: an inline style beats an ID, an ID beats a class or pseudo-class, and a class beats an element selector.
- Tag
- A name written inside angle brackets that marks where an element starts or ends, such as the opening and closing tags of a paragraph.
- Void element
- An element such as br, img, input or meta that has no content and therefore no closing tag.
Subject 2 of 2
JavaScript for Interactive Web Pages
Make web pages interactive with JavaScript: variables, conditions, loops, functions, arrays and objects, the DOM and events, form validation, a small quiz project and debugging with the browser console.
1JavaScript in a web page and the console3 min read · 4 key points · 3 exercises
Key points
- JavaScript adds behaviour to HTML and CSS pages and runs in the browser.
- Link a script file with the src attribute, usually at the end of the body.
- console.log() prints to the browser console, opened with F12.
- JavaScript is case-sensitive and different from Java.
Try this
- Create index.html and app.js, link them, and make app.js log your name to the console.
- Open the console on your page, type 12 * 5 and press Enter to see the result.
- Change console.log to Console.log on purpose and read the red error message.
2Variables, types and strings4 min read · 4 key points · 3 exercises
Key points
- Use const by default and let when a value must change.
- The main types are number, string, boolean, undefined and null.
- The + operator joins text, so convert input with Number() before adding.
- Template literals with backticks insert values into text.
Try this
- Create const variables for your name and city and let variables for age and score, then log them in one sentence using a template literal.
- Predict the result of 10 + "5" and 10 - "5", then check in the console.
- Log the length of your full name and your name in capital letters.
3Operators and making decisions4 min read · 4 key points · 3 exercises
Key points
- Use === for comparison and = for storing a value.
- && needs both conditions true, || needs at least one, ! reverses.
- if, else if and else run only the first matching block.
- switch compares one value with many fixed cases and needs break.
Try this
- Write a condition that logs "Eligible" if age is 18 or more and hasId is true.
- Write a grade program with four bands and test it with 95, 80, 40 and 10.
- Predict and then check: 5 == "5", 5 === "5" and 0 === false in the console.
4Repeating with loops3 min read · 4 key points · 3 exercises
Key points
- A for loop has a start, a condition and a step.
- While loops need something inside that eventually makes the condition false.
- break leaves a loop and continue skips one round.
- for...of visits each item of an array.
Try this
- Log the multiplication table of 12 using a for loop.
- Use a loop to add the even numbers from 2 to 20 and log the total (110).
- Loop through an array of five friends' names and log a greeting for each.
5Functions4 min read · 4 key points · 3 exercises
Key points
- Functions are declared with function or as arrow functions and run when called.
- Parameters receive the arguments passed in the call.
- return gives a value back; otherwise the result is undefined.
- Functions can be passed around as values, which is how events work.
Try this
- Write a function that takes a price and returns the price plus 18 percent, then call it with 500.
- Rewrite it as an arrow function.
- Write a function isEven(n) that returns true or false and test it with 8 and 15.
6Arrays and objects4 min read · 4 key points · 3 exercises
Key points
- Arrays are ordered lists counted from 0; push and pop change the end.
- map, filter and reduce process every item.
- Objects hold labelled properties accessed with dot notation.
- JSON is a text format for storing and sending object-like data.
Try this
- Create an array of five marks and use reduce to find the total and then the average.
- Use filter to keep only marks of 40 or more.
- Create an object for a book with title, author and price, then log the title and add a new property.
7The DOM and events4 min read · 4 key points · 3 exercises
Key points
- The DOM is the browser's object tree of the page, and JavaScript can change it.
- getElementById and querySelector select elements.
- textContent, style and classList change what the visitor sees.
- addEventListener runs a function when an event such as click occurs.
Try this
- Make a button that changes the text of a heading when clicked.
- Make a button that toggles a CSS class to switch the page between light and dark colours.
- Add an input box and show whatever the user types in a paragraph, using the input event.
8Forms and validation4 min read · 4 key points · 3 exercises
Key points
- The value of an input is text; convert it with Number() for calculations.
- event.preventDefault() stops the page from reloading on submit.
- Check for empty values, wrong types and numbers out of range, and show clear messages.
- Browser validation helps users but is not real security.
Try this
- Build the sign-up form from the lesson and test it with an empty name, an age of 3 and a valid entry.
- Add a third field for a phone number and check that it has exactly 10 digits.
- Show the error message in red text and the success message in green using classList.
9Debugging with the browser console3 min read · 4 key points · 3 exercises
Key points
- The console shows error type, message, file and line number.
- console.log with the type of a value reveals many bugs.
- Breakpoints pause code so you can inspect values step by step.
- Debug calmly: reproduce, read the error, check one thing at a time.
Try this
- Write a line that uses a misspelt variable, find the error in the console and fix it.
- Add a breakpoint inside a loop and watch a variable change as you step.
- Use console.table on an array of three student objects.
10A small project: a quiz game4 min read · 4 key points · 3 exercises
Key points
- Plan the data, the display and the logic before coding.
- An array of objects is a neat way to store quiz questions.
- Event handlers update the score and the page together.
- Small functions such as showQuestion and choose keep the project readable.
Try this
- Type the quiz, add two more questions of your own and play it.
- Show "Correct" or "Wrong" for a moment after each answer.
- Build a to-do list with an input box, an Add button and items that toggle a done class when clicked.
Glossary: 26 key terms of JavaScript for Interactive Web Pages
- JavaScript
- The programming language that adds behaviour to web pages in the browser.
- Console
- A part of the browser developer tools that shows messages and errors and lets you try code.
- Variable
- A named place that stores a value.
- let
- The keyword for a variable whose value can be changed.
- const
- The keyword for a variable that cannot be reassigned.
- String
- Text in quotes.
- Number
- The JavaScript type for whole and decimal numbers.
- Boolean
- A value that is either true or false.
- undefined
- The value of a variable that has not been given a value.
- NaN
- Not a Number: the result of an invalid numeric operation such as Number("abc").
- Operator
- A symbol such as +, === or && that works on values.
- Strict equality
- The === operator, which compares both value and type.
- Condition
- An expression that is true or false, used by if and loops.
- Loop
- Code that repeats, such as for, while or for...of.
- Function
- A named, reusable block of code.
- Parameter
- A name in a function definition that receives a value.
- Arrow function
- A short way of writing a function using =>.
- Array
- An ordered list of values with positions starting at 0.
- Object
- A collection of key: value pairs describing one thing.
- JSON
- A text format for data that resembles JavaScript objects.
- DOM
- The browser's tree of objects that represents the page and can be changed by JavaScript.
- Event
- Something that happens on the page, such as a click or a key press.
- Event listener
- A function registered with addEventListener to run when an event happens.
- Validation
- Checking that entered data is complete and sensible.
- Breakpoint
- A marked line where the debugger pauses the code so you can inspect it.
- Bug
- A mistake in a program that causes wrong behaviour.
Practice and study material
Study books and timed practice tests in the student portal
Students sign in to read the study books lesson by lesson, print them, mark lessons as done and test themselves with timed practice tests, every answer explained.
- 2study books
- 17lessons
- 75practice questions
- 51glossary terms
How the practice tests work
- Fresh questions each time
Up to 20 questions are picked at random from the subject’s question bank.
- One minute per question
A timer counts down. When it reaches zero, your answers are sent automatically.
- Move around freely
Skip a question, flag it, and come back to change your answer before you submit.
- Learn from every answer
At the end you see the right answer and an explanation for each question.
- Read, print and keep track
Each study book has its lessons, key points, exercises and a glossary. Print a lesson, or mark it as done.
Your centre gives you your login when you enrol.
Try 3 practice questions
Real questions from this course’s question banks. Pick an answer to see the explanation.
In <a href="contact.html">Contact</a>, what is href="contact.html"?
Show the answer
Answer: D. An attribute
href is an attribute: extra information written inside the opening tag as name="value".
What does "5" * 2 give?
Show the answer
Answer: C. 10
The * operator converts the text to a number, giving 10.
Which element should contain the main content that is unique to a page?
Show the answer
Answer: D. <main>
main wraps the central content of the page; the header, navigation and footer that repeat on every page stay outside it.
Careers
Careers this course leads towards
The kind of work these skills are used for. Each guide explains what the job involves, the skills it asks for and how to get started.
Web developer
Building and updating websites with HTML, CSS and JavaScript, and connecting them to data.
Software developer
Writing, testing and fixing programs in languages such as C, C++, Java and Python.
How admission works
From your first question to your certificate.
The usual steps, at the head office in Delhi or at an authorised member centre.
- Who can join
- Students above 12 years of age.
- Where
- The Delhi head office and authorised member centres.
- Fees and timings
- On WhatsApp at +91 97116 99511, or by phone on 011 2721 1512.
- 1
Ask about the course
Call or WhatsApp the head office, or visit your nearest member centre. Ask for the duration, the fee and the batch timings in writing.
- 2
Fill the admission form
Admission forms are supplied by the head office to every centre.
- 3
Learn in class
Attend your batch at the centre, with the course material and study notes, and sign in to the student portal for the study books and practice tests.
- 4
Take the exam
The institute prefers written exams, taken in front of a teacher.
- 5
Receive your certificate
Students who pass get a Gurukul Technicals Institute certificate and marksheet. Employers can verify it with the head office.
Who can join the JavaScript course?
Students above 12 years of age can take admission, at the Delhi head office or at an authorised member centre. The course suits students who know basic HTML and CSS. Tell the head office or your centre what you already know, and they will suggest where to start.
How long is the course and what is the fee?
Duration, fees and batch timings depend on the course and the centre. Ask the head office or your nearest member centre, and get the details in writing before you pay.
Where are the classes?
At the head office in Delhi (A-10, Chief Commissioner Colony, opposite Rana Pratap Bagh) and at authorised member centres. Call or WhatsApp the head office to find the nearest centre.
What do I need to use the study books and practice tests?
A phone or a computer with an internet connection, and the login your centre gives you at enrolment. The student portal opens in an ordinary web browser, so there is nothing to install. Student login.
How do the practice tests work?
Sign in to the student portal and choose a subject. Each test picks up to 20 questions at random from that subject’s question bank and gives you one minute per question, with a timer that sends your answers automatically when it reaches zero. You can skip a question, flag it and come back before you submit, and at the end you see the right answer and an explanation for every question. This course has 75 practice questions across 2 subjects, and you can take the tests as often as you like.
Is there an exam and a certificate?
Yes. The institute prefers written exams, taken in front of a teacher. Students who pass receive a Gurukul Technicals Institute certificate and marksheet.
How is a Gurukul Technicals Institute certificate verified?
On the verify certificate page, anyone can enter a certificate number and check it against the institute’s online register, which covers certificates issued through the portal. For older certificates, or if there is any doubt, send a copy to the head office by email or WhatsApp; the reply comes within 2 working days.
Ready to start the JavaScript course?
Ask the head office for the duration, the fee, the batch timings and your nearest member centre.
