โœฆ The Coding Studio that explains everything

Build Sites.
Understand Every
Line of Code.

CodeIndex generates dynamic, real-world website templates and teaches you exactly how they're built โ€” line by line, language by language.

homepage.html โ€” CodeIndex Studio
1<!-- ๐Ÿ  Navigation -->
2<nav class="main-nav">
3 <div class="logo">CodeIndex</div>
4</nav>
5 
6<!-- ๐ŸŒŸ Hero Section -->
7<section class="hero">
8 <h1>Build the <span>Web</span></h1>
9 <p>Learn to code, one line at a time.</p>
10</section>
Choose a Template
// Each template is a real site. Every line explained.
Beginner
Agency Homepage โ†—
A polished marketing homepage with nav, hero, features, and CTA sections.
HTML5 CSS3 JS
Intermediate
Blog Platform NEW โ†—
Dynamic blog layout with sidebar, tags, pagination and reading time.
Ruby ERB CSS
Advanced
SaaS Dashboard โ†—
Full dashboard with sidebar nav, charts, data tables and dark mode.
HTML CSS Grid JS ES6+
{ api: response }
Advanced
REST API + Frontend โ†—
Full Rails API backend with a vanilla JS frontend consuming JSON endpoints.
Rails API Fetch API
โœฆ Digital Agency

We build the digital
brands of tomorrow

Strategy, design and development for brands that want to make a mark. We craft experiences people remember.

View Our Work Get in Touch

What we do

๐ŸŽจ

Brand Design

Visual identities that communicate your values and connect with your audience.

๐Ÿ’ป

Web Development

Fast, accessible, and beautifully engineered sites built to scale.

๐Ÿ“ˆ

Growth Strategy

Data-driven campaigns and content that move the needle.

๐Ÿ“„ agency-homepage.html HTML/CSS/JS
1
<!DOCTYPE html>
โ–ผ explain
Line 1 โ€” DOCTYPE Declaration โšก Memorise
This must be the very first line of every HTML file. It tells the browser which version of HTML to use. <!DOCTYPE html> means "use modern HTML5." Without it, browsers enter "quirks mode" and render things unpredictably.
2
<html lang="en">
โ–ผ explain
Line 2 โ€” Root HTML Element ๐Ÿ’ก Understand
The <html> element wraps everything on the page. The lang="en" attribute tells search engines and screen readers the page is in English โ€” this is important for accessibility and SEO.
3 4 5 6
<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width"> </head>
โ–ผ explain
Lines 3โ€“6 โ€” The <head> Block โšก Memorise
The <head> contains metadata โ€” information about the page that isn't shown to users.

charset="UTF-8" โ€” Enables all characters (emojis, accented letters, etc.) to display correctly.

viewport meta โ€” This is what makes sites responsive. Without it, mobile browsers zoom out to fit a desktop-width page. width=device-width tells the browser to match the device screen width.
10 11 12 13 14
<nav class="main-nav"> <div class="logo">Nova<span>Studio</span></div> <ul class="nav-links"> <li><a href="#work">Work</a></li> </ul> </nav>
โ–ผ explain
Lines 10โ€“15 โ€” Semantic Navigation ๐Ÿ” Pattern
We use <nav> instead of <div> because it's semantic HTML โ€” it tells the browser (and screen readers) "this is site navigation".

The <ul> โ†’ <li> โ†’ <a> pattern is the standard for nav links. href="#work" links to an element with id="work" on the same page โ€” an anchor link.
20 21 22 23
.main-nav { display: flex; justify-content: space-between; align-items: center; }
โ–ผ explain
CSS โ€” Flexbox Navigation โšก Memorise
Flexbox is the modern way to lay things out in a row or column.

display: flex โ€” turns on flexbox. Items line up in a row.
justify-content: space-between โ€” pushes the logo to the far left, and nav links to the far right.
align-items: center โ€” vertically centres the logo and links.
30 31 32 33 34 35
<section class="hero" id="home"> <div class="hero-content"> <span class="tag">โœฆ Digital Agency</span> <h1>We build <span>digital</span> brands</h1> <p>Strategy and development for tomorrow.</p> <a href="#work" class="btn">View Work</a> </div> </section>
โ–ผ explain
Lines 30โ€“37 โ€” Hero Section Structure ๐Ÿ” Pattern
<section> is a semantic HTML5 element. It groups related content. Adding id="home" lets anchor links scroll here.

Notice the wrapper div pattern: the outer <section> controls background/full-width, while the inner class="hero-content" div controls the max-width and padding.

The <span> inside <h1> lets us colour just one word โ€” a common design technique.
1 2 3 4 5
:root { --primary: #7c6fff; --bg: #0a0a0f; --text: #e8e8f0; --radius: 10px; }
โ–ผ explain
CSS Variables (Custom Properties) โšก Memorise
:root targets the top of the document. Variables defined here are available everywhere.

To use them: color: var(--primary). If you want to rebrand the whole site, change --primary once. This is professional CSS architecture.
20 21 22 23
.hero { background: linear-gradient( 135deg, #0a0a12 0%, #12102a 50%, #0a1520 100%); }
โ–ผ explain
CSS Gradient Backgrounds ๐Ÿ’ก Understand
linear-gradient() blends colours in a straight line.

135deg โ€” the angle. 0deg is bottom to top; 90deg is left to right; 135deg is diagonal (top-left to bottom-right).

The colour stops (0%, 50%, 100%) control where each colour appears along the gradient.
YOUR STUDY NOTES
โšก Memorise Key Lines to Know by Heart
โ†’ <!DOCTYPE html> โ€” always first
โ†’ charset + viewport meta โ€” always in head
โ†’ display: flex โ€” layout workhorse
๐Ÿ’ก Understand Concepts to Grasp
โ†’ Semantic HTML โ€” meaning over divs
โ†’ Box model โ€” padding, border, margin
โ†’ Specificity โ€” why your CSS sometimes loses

HTML Basics

HTML (HyperText Markup Language) is the skeleton of every web page. It describes the structure and meaning of content using elements โ€” paired tags that wrap content.

example.html
/* Every HTML element looks like this: */ <tagname attribute="value"> โ† opening tag Content goes here </tagname> โ† closing tag /* Self-closing tags (no content needed): */ <img src="photo.jpg" alt="A photo"> <br> <hr> <input>

DOCTYPE Declaration

The <!DOCTYPE html> declaration is not an HTML tag โ€” it's an instruction to the browser. It must be the very first line of your file, before even the <html> tag.

Without it, browsers render in "quirks mode" โ€” an old compatibility mode that causes layout bugs.

1 Exercise โ€” Write a minimal HTML page
Write the five lines every HTML page must start with: the DOCTYPE, opening html tag, head with a title, and an opening body tag.
<!DOCTYPE html> <html lang="en"> <head> <title>My Page</title> </head> <body>

HTML Attributes

Attributes provide extra information about an element. They always go in the opening tag, written as name="value" pairs.

attributes.html
/* Common attributes and what they do: */ <a href="https://example.com">Link</a> โ† where it goes <img src="photo.jpg" alt="Sunset"> โ† source + accessible text <div class="card" id="main"> โ† CSS hooks <input type="text" placeholder="Search">
2 Exercise โ€” Add attributes
Write an image tag that shows "logo.png", with alt text of "Company Logo", and a class of "site-logo".
<img src="logo.png" alt="Company Logo" class="site-logo">

Semantic HTML

Semantic HTML means using elements that describe their meaning, not just their appearance. A <nav> means navigation. A <main> means primary content. This matters for accessibility, SEO, and readability.

semantic.html
/* โŒ Non-semantic (all divs โ€” machines can't understand) */ <div class="nav">...</div> <div class="header">...</div> <div class="content">...</div> /* โœ… Semantic (clear meaning for everyone) */ <nav>...</nav> <header>...</header> <main>...</main> <article>...</article> <aside>...</aside> <footer>...</footer>

The correct HTML pattern for navigation is always: <nav> wrapping a <ul> (unordered list) of <li> items containing <a> links. This is what screen readers expect.

CSS Layout

CSS layout determines how elements are positioned and sized on screen. The two main modern tools are Flexbox (one dimension) and Grid (two dimensions).

Flexbox

Flexbox arranges items in a row or column. It's perfect for navbars, button groups, and any single-axis alignment problem.

flexbox.css
.container { display: flex; /* activate flexbox */ flex-direction: row; /* row (default) or column */ justify-content: center; /* main axis alignment */ align-items: center; /* cross axis alignment */ gap: 16px; /* space between items */ flex-wrap: wrap; /* wrap to next line if needed */ } /* justify-content values: */ /* flex-start | flex-end | center | space-between | space-around */
3Exercise โ€” Flexbox Nav
Write CSS to make a .nav display as a horizontal row with the logo on the far left and links on the far right, both vertically centred.
.nav { display: flex; justify-content: space-between; align-items: center; padding: 16px 32px; }

CSS Variables

CSS custom properties (variables) store values you reuse throughout a stylesheet. Defined on :root to be globally available.

variables.css
:root { --color-brand: #7c6fff; --font-size-base: 16px; --spacing-md: 24px; } /* Using variables: */ .button { background: var(--color-brand); padding: var(--spacing-md); font-size: var(--font-size-base); } /* Override in a component: */ .dark-theme { --color-brand: #ff6b6b; /* overrides locally */ }

CSS Gradients

Gradients create smooth transitions between colours. They're set as background values โ€” not colours themselves.

gradients.css
/* Linear gradient โ€” straight line */ background: linear-gradient(to right, #7c6fff, #ff6b6b); background: linear-gradient(45deg, #000 0%, #333 100%); /* Radial gradient โ€” radiates from center */ background: radial-gradient(circle, #7c6fff 0%, transparent 70%); /* Multiple layers (last = bottom): */ background: radial-gradient(circle at top right, rgba(124,111,255,.2), transparent 60%), linear-gradient(180deg, #0a0a12, #0d0d20);
4Exercise โ€” Gradient Hero
Write a CSS background that fades diagonally (135 degrees) from a very dark navy (#0a0a12) to a dark purple (#12102a) to a dark teal (#0a1520).
background: linear-gradient( 135deg, #0a0a12 0%, #12102a 50%, #0a1520 100% );

Responsive Design

Responsive design means your site works beautifully on any screen size โ€” from a 320px phone to a 4K monitor. The core tools are the viewport meta tag, CSS media queries, and relative units.

responsive.css
/* Mobile-first: write base styles for small screens */ .grid { display: grid; grid-template-columns: 1fr; /* 1 column on mobile */ gap: 16px; } /* Then override for larger screens: */ @media (min-width: 768px) { .grid { grid-template-columns: repeat(2, 1fr); /* 2 cols on tablet */ } } @media (min-width: 1024px) { .grid { grid-template-columns: repeat(3, 1fr); /* 3 cols on desktop */ } }

Accessibility

Accessible HTML works for everyone โ€” including people using screen readers, keyboard navigation, or other assistive technologies. Good accessibility is also good SEO.

accessibility.html
/* Always add alt text to images: */ <img src="team.jpg" alt="The NovaStudio team at the office"> /* Use proper heading hierarchy: */ <h1>Main page title</h1> โ† only one per page <h2>Section title</h2> <h3>Sub-section</h3> /* Label form inputs: */ <label for="email">Email</label> <input type="email" id="email">
Same Site, Different Languages
// The same navigation component, built three ways
HTML / CSS / JS
<!-- Pure HTML navigation --> <nav class="nav"> <a href="/">Home</a> <a href="/about">About</a> </nav>
โ–ผ explain
HTML Approach
Simple, static HTML. The nav links are hardcoded. CSS handles styling, and JavaScript might add a hamburger menu toggle. Best for: simple sites, beginners, static content.
Ruby on Rails (ERB)
<%# Rails ERB navigation partial %> <nav class="nav"> <%= link_to "Home", root_path %> <%= link_to "About", about_path %> <% if user_signed_in? %> <%= link_to "Dashboard", dashboard_path %> <% end %> </nav>
โ–ผ explain
Ruby on Rails Approach
ERB (Embedded Ruby) mixes Ruby code into HTML. <%= %> outputs a value. <% %> runs code without output. link_to generates a correct anchor tag using Rails named routes. Conditionally show the dashboard link only if a user is logged in.
Key Differences
LINKING
HTML: Hardcoded paths like /about

Rails: Named routes like about_path โ€” Rails auto-generates the URL. Change the route once, updates everywhere.
DYNAMIC CONTENT
HTML: Needs JavaScript to show/hide elements based on state.

Rails: Ruby logic runs server-side. if user_signed_in? is evaluated before HTML is sent to the browser.
REUSE
HTML: Copy-paste across pages.

Rails: Partials (_nav.html.erb) are included with render 'nav' โ€” write once, use everywhere.