A Beginner's Guide to Starting with HTML, CSS, and JavaScript
Everything you need to go from a blank text editor to a working, useful webpage Every website you've ever visited — no matter how complex — is built on three foundations: HTML, CSS, and JavaScript. Frameworks and libraries sit on top of these three; they don't replace them. This guide goes deep into each one individually, then walks through building a genuinely useful project — a personal task…
<h1>HTML</h1>
HTML (HyperText Markup Language) defines the structure of a webpage. It does not contain any logic or calculations – it simply organizes content using tags.
The basic structure of an HTML document consists of three main parts:
<ol>
<li>!DOCTYPE html – tells the browser this is an HTML5 document. It must be the first line.</li>
<li>html lang="en" – the root element that wraps everything on the page. The lang attribute helps screen readers and search engines determine the language.</li>
<li>head – contains metadata that does not affect what users see. It includes character encoding, page title, linked CSS and JavaScript files, and SEO tags.</li>
<li>body – this is where all the visible content goes, such as headings, paragraphs, images, and other elements.</li>
</ol>
Within the <body>, tags specify elements. A tag is the syntax itself (e.g., <p>), while an element includes the tag plus its content and closing tag (e.g., <p>This is a paragraph.</p>). Attributes provide additional information inside the opening tag, like href for links or id for uniquely identifying elements. Most tags come in pairs like <p>...</p>, except for self-closing tags like <img> and <br> which do not wrap content.
Semantic tags such as <header>, <nav>, <section>, and <footer> provide meaning about the purpose of an area, helping accessibility tools, search engines, and future developers understand the page structure. For generic layout boxes, the <div> tag is used.
<h2>CSS</h2>
CSS (Cascading Style Sheets) is used to control the visual appearance of HTML elements—color, spacing, fonts, sizing, and layout.
There are three ways to add CSS:
<ul>
<li>Inline – applying styles directly on an element using the style attribute. Not recommended for production code.</li>
<li>Internal – defining styles within a <style> tag in the <head> of an HTML document. Suitable for small pages.</li>
<li>External – placing styles in a separate .css file referenced with a <link> element in the document head. This separates content and presentation, making it scalable for larger projects.</li>
</ul>
CSS selectors allow targeting elements for styling:
<ul>
<li>Pure element selectors (e.g., p { ... }) target all instances of a specific element.</li>
<li>Class selectors (e.g., .highlight { ... }) match elements with a particular class attribute, useful for reusable styles.</li>
<li>ID selectors (e.g., #main-title { ... }) target a single unique element per page, often used for distinctive elements like headings.</li>
<li>Pseudo-classes (e.g., button:hover { ... }) define styles based on an element's state, like when the mouse hovers over a button.</li>
</ul>
The box model describes how every HTML element is rendered as a rectangular box with four components:
1. Content – the actual text, images, or other content inside the box.
2. Padding – space between the content and the border.
3. Border – a surrounding outline that goes around the padding and content.
4. Margin – space outside the border.
These layers can be controlled and styled individually, allowing precise control over an element's appearance.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.