HTML and CSS Basics Every Shopify Beginner Should Know
The small set of HTML and CSS you actually need before touching Shopify Liquid: structure, classes, spacing, flexbox and mobile layout.
Share with Shopify developers — useful guides spread faster in theme dev communities.
Why HTML and CSS come first
Liquid does not replace HTML. A Shopify section is HTML with placeholders for store data. If you can read and write basic HTML and CSS, Liquid becomes easy.
HTML: the 10 tags you will use most
<section> a block of the page
<h1> to <h6> headings
<p> a paragraph
<a href="/collections/all"> a link
<img src="photo.jpg" alt="Describe the image"> an image
<ul> and <li> a list
<div> a generic box
<button> a button
<form> and <input> forms
<span> a piece of inline text
Always write alt text on images. It helps accessibility and SEO.
A first section in plain HTML
<section class="hero">
<h2 class="hero__title">Fresh arrivals</h2>
<p class="hero__text">New styles added every week.</p>
<a href="/collections/new" class="hero__button">Shop now</a>
</section>
The class names connect the HTML to your CSS. Use a clear pattern such as block__element so names never clash with the theme.
CSS: the basics
.hero {
padding: 48px 20px;
text-align: center;
background: #f1f5f9;
}
.hero__title { font-size: 32px; margin: 0 0 8px; }
.hero__button {
display: inline-block;
padding: 12px 24px;
background: #111827;
color: #fff;
border-radius: 8px;
text-decoration: none;
}
- padding is space inside a box; margin is space outside.
- font-size, color and background control text and colours.
- border-radius rounds corners.
Layout: flexbox and grid
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.row { display: flex; gap: 12px; align-items: center; }
The auto-fit grid above is responsive without any media query. Cards wrap onto new lines on small screens.
Mobile first
Most Shopify visitors use phones. Write CSS for small screens first, then add @media (min-width: 768px) for larger ones. Test with your browser's device toolbar.
Practice task
- Write the hero section above in a file called
index.html. - Style it with the CSS above and open it in your browser.
- Paste the HTML and CSS into the converter and look at the Liquid it produces.
Takeaway
You do not need to master all of HTML and CSS. Learn the tags above, classes, spacing, flexbox and grid. Next, learn how Shopify fills these pages with data in The Ultimate Shopify Liquid Beginner Guide.
Need a hand?
If you get stuck, our senior Shopify developers Nishad Kikani and Dhruv Goyani can help. Send your question through the contact form (name, email, subject and message) and describe what you want to build. You can also read about them on the Meet the founders page.
Practice: build a two-column feature block
The fastest way to learn is to build one small layout and break it on purpose. Create a plain HTML file and try this feature block. It is the same kind of markup you will later turn into a Shopify section.
<section class="feature">
<img src="photo.jpg" alt="Handmade ceramic mug" width="600" height="400">
<div class="feature__text">
<h2>Made to be used daily</h2>
<p>Each mug is thrown by hand and fired twice.</p>
<a href="/collections/mugs">Shop mugs</a>
</div>
</section>
<style>
.feature { display: grid; gap: 1.5rem; padding: 2rem 1rem; }
.feature img { width: 100%; height: auto; border-radius: 8px; }
@media (min-width: 768px) {
.feature { grid-template-columns: 1fr 1fr; align-items: center; }
}
</style>
On a phone the image stacks above the text. From 768px wide the two sit side by side. That one media query is the pattern behind most responsive Shopify sections: design the small screen first, then add rules as the screen grows.
Three CSS habits that save you later
- Use rem and percentages, not fixed pixels, for text and spacing so the layout respects the visitor's font size settings.
- Always set width and height on images. The browser reserves the space before the image loads, which prevents the page from jumping (layout shift).
- Prefer class selectors over tag selectors. A rule like
h2 { color: red }will leak into the rest of a theme. A rule like.feature h2will not.
Check yourself
- Resize the browser window. Does the layout change at 768px?
- Zoom the page to 200%. Is the text still readable without side-scrolling?
- Turn off images. Does the alt text still describe each picture?
When all three pass, you are ready to move this markup into a theme. Our worked conversion example shows exactly how.
Topic cluster
Shopify Sections
OS 2.0 sections, JSON templates, and section architecture.
Convert your HTML to Shopify Liquid
Paste a module, generate Liquid + schema, then copy the result into your theme. Free to try—no signup required for a sample conversion.
Share
Share this guide
Found this guide useful? Share it with other Shopify developers on LinkedIn, X, or Reddit.