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<navclass="main-nav">
3<divclass="logo">CodeIndex</div>
4</nav>
5
6<!-- ๐ Hero Section -->
7<sectionclass="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.
HTML5CSS3JS
Intermediate
Blog Platform NEWโ
Dynamic blog layout with sidebar, tags, pagination and reading time.
RubyERBCSS
Advanced
SaaS Dashboard โ
Full dashboard with sidebar nav, charts, data tables and dark mode.
HTMLCSS GridJS ES6+
{ api: response }
Advanced
REST API + Frontend โ
Full Rails API backend with a vanilla JS frontend consuming JSON endpoints.
Rails APIFetch API
CodeIndex/Template Studio/Agency HomepageClick any line of code โ expand explanation
โฆ 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 WorkGet 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
Document Structure
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.
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.
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.
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.
<sectionclass="hero"id="home"><divclass="hero-content"><spanclass="tag">โฆ Digital Agency</span><h1>We build <span>digital</span> brands</h1><p>Strategy and development for tomorrow.</p><ahref="#work"class="btn">View Work</a></div></section>
<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.
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: */<tagnameattribute="value">โ opening tag
Content goes here
</tagname>โ closing tag/* Self-closing tags (no content needed): */<imgsrc="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.
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: */<ahref="https://example.com">Link</a>โ where it goes<imgsrc="photo.jpg"alt="Sunset">โ source + accessible text<divclass="card"id="main">โ CSS hooks<inputtype="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".
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) */<divclass="nav">...</div><divclass="header">...</div><divclass="content">...</div>/* โ Semantic (clear meaning for everyone) */<nav>...</nav><header>...</header><main>...</main><article>...</article><aside>...</aside><footer>...</footer>
Navigation Patterns
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.
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: */<imgsrc="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: */<labelfor="email">Email</label><inputtype="email"id="email">
CodeIndex/Language Comparison
Same Site, Different Languages
// The same navigation component, built three ways
HTML / CSS / JS
<!-- Pure HTML navigation --><navclass="nav"><ahref="/">Home</a><ahref="/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.
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.