What you will learn
- Explain the separate jobs of HTML, CSS and JavaScript
- Recognize semantic page structure and basic styling
- Describe how browser scripts respond to user interaction
How a browser displays a web page
A browser receives resources from a website and uses web standards to display the page. A simple site commonly uses HTML, CSS and JavaScript. These technologies have different responsibilities, so a project is easier to maintain when each is used for its intended purpose.
HTML: structure and meaning
HTML stands for HyperText Markup Language. It describes the structure of the page with elements. A heading identifies a section title, a paragraph groups text, a link points to another resource and a form collects user input.
Semantic HTML uses elements that communicate the role of content. For example, <main> identifies the primary page content, <nav> identifies navigation and <article> can represent a self-contained piece of content. Meaningful structure helps browsers, assistive technologies and maintainers understand the page.
CSS: presentation and layout
CSS stands for Cascading Style Sheets. It controls how HTML content looks: colors, spacing, typography, borders and layout. CSS can also adapt a page to different screen sizes.
A simple CSS rule has a selector and declarations. For example:
h1 {
font-size: 2rem;
line-height: 1.2;
color: #173b8f;
}
This rule selects heading elements and sets their size, line height and text color. The content remains in the HTML; CSS changes its presentation.
JavaScript: behavior and interaction
JavaScript is a programming language used by browsers to add behavior. A script can respond to a button click, validate form input, update part of a page or request information from a server.
const button = document.querySelector("#show-message");
const output = document.querySelector("#message");
button.addEventListener("click", () => {
output.textContent = "The button was pressed.";
});
This example finds a button and a message area, then changes the message when the button is clicked. The HTML needs matching elements with the IDs used by the script.
How the three technologies work together
HTML creates the button and message area. CSS makes them readable and visually clear. JavaScript defines what happens when the visitor activates the button. This separation makes changes easier: the text can change without rewriting the styling, and the design can change without changing the interaction logic.
Build a small page in stages
- Create an HTML file with a page title, main heading, paragraph and link.
- Add a CSS file and style the text, spacing and page width.
- Add a button and a message element with unique IDs.
- Load a JavaScript file and add a click event listener.
- Open the page in a browser and test keyboard and pointer interaction.
- Resize the browser and check that content remains usable on a narrow screen.
Accessibility and quality basics
Use headings in a logical order, provide labels for form controls, write useful link text and add alternative text for meaningful images. Make sure the page can be navigated with a keyboard. Do not rely on color alone to communicate important information.
Also test your page in more than one viewport. A page that looks correct on a large monitor may have overflowing content or tiny controls on a phone. Use browser developer tools to inspect errors and test changes carefully.
Quick review
- HTML describes page structure and meaning.
- CSS controls presentation and layout.
- JavaScript adds behavior and interaction.
- Semantic elements help communicate content roles.
- Testing includes accessibility and small-screen layouts.
Further reading
- MDN Web Docs: Learn web development
- MDN Web Docs: The web standards model
- WHATWG: HTML Living Standard
- MDN Web Docs: JavaScript Guide