freeCodeCamp - Learn HTML by Building a Cat Photo App

Embarking on the journey of learning web development can be both exciting and overwhelming. With countless resources available, it’s easy to get lost in the sea of tutorials and courses. One of the trusted platforms for beginners is freeCodeCamp, known for its hands-on, project-driven learning approach. In this comprehensive guide, we’ll walk through the process of mastering HTML fundamentals by building a fun and interactive Cat Photo App, inspired by freeCodeCamp’s Responsive Web Design Certification.
Whether you’re completely new to coding or looking to refresh your skills, this step-by-step breakdown will help you understand essential HTML concepts such as elements, attributes, forms, semantic tags, and accessibility—all while creating a practical web project. Let’s dive in and build a solid foundation in web design!
Video Walkthrough
Getting Started: Setting Up Your Learning Environment
Before diving into coding, you’ll want to sign up on freeCodeCamp and navigate to the Responsive Web Design Certification. The Cat Photo App project is a great starting point as it introduces HTML basics and progressively builds complexity.
The project is broken down into multiple steps, each focusing on a particular HTML concept. By following along and coding in the embedded editor, you’ll see real-time previews of your work. This immediate feedback loop is invaluable when learning how HTML structures web pages.
Understanding HTML Elements and Structure
The first steps focus on understanding the core building blocks of HTML: elements and tags. An HTML element typically has an opening tag, content, and a closing tag. For instance, a heading element looks like this:
<h1>Cat Photo App</h1>
Here, the
<h1>
tag denotes the most important heading, and the text inside is what gets displayed on the page. freeCodeCamp emphasizes the importance of using heading tags from h1
to h6
to signify content hierarchy, where h1
is the highest level and should appear only once per page.It’s also essential to nest elements properly for readability and maintainability. Indentation helps developers understand the document’s structure at a glance, although browsers do not require it. For example, nested elements inside a
<main>
tag should be indented:<main>
<h1>Cat Photo App</h1>
<p>Everyone loves cats.</p>
</main>
Adding Content with Paragraphs and Comments
The paragraph element, denoted by
<p>
, is used to add blocks of text content. Unlike headings, paragraphs are not bold and typically have some default margin for spacing, making them ideal for regular text.Comments in HTML, wrapped with
<!-- comment text -->
, are not rendered by browsers but serve as notes for developers. They’re useful for leaving reminders or explanations within your code. For example, adding a to-do comment helps keep track of pending tasks without affecting the page’s display.Working with Images and Accessibility
Images are added using the
<img>
tag, which is unique because it is a void element—it does not require a closing tag. The src
attribute specifies the image source URL, while the alt
attribute provides alternative text for screen readers and displays if the image fails to load. This enhances accessibility for users with visual impairments.Example of an image tag with attributes:
<img src="https://example.com/cat.jpg" alt="A cute cat">
Always remember to include meaningful alt text. If an image is broken or cannot be loaded, the alt text will inform users about what should have been displayed.
Creating Links with Anchor Tags
The
<a>
tag is used to create hyperlinks. The href
attribute defines the URL the link points to. Text or images wrapped inside the anchor tag become clickable elements.For example, to link text:
Additionally, adding the
target="_blank"
attribute opens the link in a new tab, improving user experience when navigating external sites.Structuring Content with Semantic HTML Elements
Semantic elements like
<main>
, <section>
, <figure>
, <figcaption>
, and <footer>
help define the meaning of different parts of your webpage. They improve accessibility, SEO, and provide better organization both for developers and browsers.- Main: Wraps the primary content of the page.
- Section: Groups related content into thematic blocks.
- Figure & Figcaption: Used for self-contained content such as images with captions.
- Footer: Contains metadata like author info, copyright, or contact details.
For example, wrapping an image and its caption:
<figure>
<img src="lasagna.jpg" alt="Slice of lasagna on a plate">
<figcaption>Cats love <em>lasagna</em>.</figcaption>
</figure>
Notice how the
<em>
tag emphasizes the word “lasagna” by italicizing it, which also provides verbal emphasis for screen readers.Creating Lists: Ordered and Unordered
Lists are essential for organizing related items. There are two main types:
- Unordered Lists (
<ul>
): Display bullet points.
- Ordered Lists (
<ol>
): Display numbered items.
List items are added using the
<li>
tag inside either <ul>
or <ol>
. For example:Building Forms: Collecting User Input
Forms are a critical part of interactive websites, allowing you to gather data from users. The
<form>
element wraps input fields and buttons.Key form elements and attributes include:
- Input Fields (
<input>
): Collect user data. Thetype
attribute defines the kind of input, such as text, radio buttons, or checkboxes.
- Name Attribute: Identifies the input's data when the form is submitted.
- Placeholder: Provides hint text inside the input field.
- Required: Ensures the user cannot submit the form without filling out the field.
- Button (
<button>
): Allows form submission.
Example of a text input field with attributes:
<input type="text" name="catPhotoURL" placeholder="catphotourl" required>
The submit button:
<button type="submit">Submit</button>
Working with Radio Buttons and Checkboxes
Radio buttons are used when a user must select one option from a set, while checkboxes allow multiple selections.
Each radio button or checkbox should have:
- An
id
attribute for unique identification.
- A
name
attribute to group related inputs (especially important for radio buttons).
- A
value
attribute representing the data sent on submission.
- An associated
<label>
element with afor
attribute matching the input’sid
to improve accessibility and usability.
Example of radio buttons for “Indoor” and “Outdoor” cats:
Grouping inputs inside
<fieldset>
with a <legend>
provides a clear context for users and screen readers, improving form usability.Enhancing Accessibility and SEO with Metadata
Beyond visible content, the
<head>
section of your HTML document contains metadata that helps browsers and search engines understand your page. This includes the <title>
tag, which sets the text displayed on the browser tab.For example:
Additionally, specifying the language of your document using the
lang
attribute on the root <html>
tag aids screen readers and search engines:<html lang="en">
Finally, every HTML document should start with the declaration to ensure browsers render the page in standards mode, following modern web specifications.
Wrapping Up the Cat Photo App Project
By following this structured approach, you’ve built a functional Cat Photo App that covers a wide range of HTML concepts. From basic elements like headings and paragraphs to more advanced topics such as forms, semantic tags, accessibility features, and metadata, this project serves as a solid foundation for responsive web design.
Key takeaways include:
- Understanding the anatomy of HTML elements and proper nesting.
- Using semantic HTML to improve page structure and accessibility.
- Implementing forms with validation and user-friendly input controls.
- Enhancing accessibility with alt text, labels, and ARIA best practices.
- Adding metadata and language attributes for SEO and usability.
As you continue your web development journey, remember that practice and building projects like this are invaluable. The Cat Photo App project is part of freeCodeCamp’s Responsive Web Design Certification, which offers further challenges and learning opportunities.
Keep experimenting, building, and refining your skills. Happy coding!