HTML Fundamentals & Structure
HTML provides the skeleton and structural backbone of every webpage.
<head> vs <body>
Every standard HTML document is cleanly split into two distinct areas:
<head>: Contains metadata, page title, character encoding, SEO tags, and links to external CSS stylesheets and fonts. This part is not rendered visually on the webpage.<body>: Contains all the visual content the user actually sees and interacts with (headings, text, buttons, images, videos, links).
Anchor Tag (<a>) & href
The Anchor Tag (<a>) defines a hyperlink to connect pages or resources. The href (Hypertext REFerence) attribute tells the browser where to navigate:
- External Link:
href="https://google.com"withtarget="_blank"(opens new tab). - Internal Page:
href="about.html". - Page Anchor:
href="#section-id"(smooth jumps to an ID). - Email & Phone:
href="mailto:user@domain.com"ortel:+123.
HTML Attributes Explained
Attributes provide extra instructions and details for an HTML element. They are always written inside the opening tag in name="value" pairs:
id="...": Unique identifier for an element (one per page).class="...": Reusable label for styling multiple elements.src="...": Source path for images, audio, or scripts.alt="...": Alternative text for images (vital for accessibility).target="_blank": Instructs browser to open a link in a new tab.
Headings (<h1>-<h6>) & Paragraphs (<p>)
Text hierarchy organizes information for readers and search engines:
<h1>to<h6>: Headings represent rank and importance. A page should typically have exactly one<h1>for SEO.<p>: Defines a paragraph block with automatic spacing.<br>: Inserts a single line break inside text.<hr>: Inserts a thematic divider horizontal rule.
Main Page Title (h1)
Subheading Topic (h2)
This is an example paragraph demonstrating natural typography and body text flow.
Adding Images (<img>)
The <img> tag is an empty / self-closing element used to embed images:
src="...": Path to the image file (e.g.profile.jpgor external URL).alt="...": Text read by screen readers and displayed if the image fails to load.width&height: Sets dimensions to prevent layout shifts.
CSS Styling, Colors & Design
CSS controls how HTML elements are painted, positioned, styled, and brought to life.
3 Ways to Apply CSS
CSS can be included in three distinct ways:
- 1. External Stylesheet (Recommended): Linked in
<head>via<link rel="stylesheet" href="style.css">. Cleanest, easiest to maintain. - 2. Internal Styles: Written inside
<style>tags inside the<head>. Great for single-page templates. - 3. Inline Styles: Written directly inside the element's
style="..."attribute. Useful for quick one-off overrides.
Background Color & Gradients
The background-color property sets a solid color, while background supports smooth linear and radial gradients:
- Named colors:
white,blue,black. - Hex codes:
#0070f3(Royal Blue),#0f172a(Slate Dark). - RGB / RGBA:
rgba(0, 112, 243, 0.25)(includes opacity). - Linear Gradients:
linear-gradient(135deg, #0070f3, #0ea5e9).
#0070f3
Text Color & Font Styling
CSS gives you complete control over text appearance:
color: Defines the color of the text characters.font-family: Specifies fonts (e.g.'Inter', sans-serif).font-size: Sets size inpx,rem, orclamp().font-weight: Controls thickness (400 normal, 700 bold).text-align: Aligns text (left,center,right).
"Clean code creates beautiful experiences."
Styling Images with CSS
Raw HTML images can overflow or look flat. CSS transforms them into modern components:
max-width: 100%; height: auto;: Makes images fully responsive on mobile.border-radius: 12px;: Softens harsh corners;50%makes circular avatars.object-fit: cover;: Prevents image distortion or squishing.box-shadow&transform: hover: Creates depth and 3D hover lift.
Square & Flat
Rounded, Border & Shadow
The CSS Box Model
Every HTML element on a webpage is a rectangular box made of four layers:
- Content: The text, image, or video inside the box.
- Padding: Transparent inner space around the content.
- Border: The line wrapping around the padding.
- Margin: Space outside the border separating elements from neighbors.