Formatting Sections in Shopify with HTML and CSS
The idea behind the e-commerce platform Shopify is to offer businesses an all-in-one solution for online presence and online sales that is as easy to use as possible. It is meant to give...

The idea behind the e-commerce platform Shopify is to offer businesses an all-in-one solution for online presence and online sales that is as easy to use as possible. It is meant to give all entrepreneurs the opportunity to set up and run a working online shop without much effort or technical knowledge.
This focus on simple, easy-to-grasp operation, however, often means that detailed customisation options are not shown in the Shopify editor, or only partially. For example, when you create a new page for your shop, you can modify it with HTML and CSS code. However, this option is missing for the sections you use to design your home page (with the Dawn theme, these sections are now even available for almost all pages of your shop).
Here we show you how to change this with just a few clicks so that you can use HTML and CSS within the sections too – and design your home page to be even more individual and better suited to you, your company and your products or services.
Caution: in this guide you will make a change in your theme’s code. We strongly recommend creating a backup of your theme before every change to the code. To do so, simply duplicate your current theme and give the copy a recognisable name (e.g. theme name + “Backup” + date):

Duplicate your theme before editing it to create a backup!
The standard sections in the Shopify editor
Let’s take as an example this section named “Image with text overlay” (German: “Foto mit überlegtem Text”) in the Debut theme. In the menu on the left you can select the image, you have various layout options for the section and a text field in which you can write the text that should appear on the image. Unfortunately, here you can only set the text in bold (B) and italics (I) or insert a link.
If you want to use further formatting options beyond that: don’t despair, because the solution is quite simple, and we’ll show you how it works here!

The text you enter in the field on the left then appears on the image.
Find out the internal name of the section
First you need to find out what the section in question is called in Shopify’s code. If you use the Chrome browser, you can right-click on the section and select the “Inspect” option to view the page’s code in a developer console. If you hover the mouse pointer over individual lines of code, the corresponding area on the web page is highlighted – as you can see in the image here:

Left: the inspected element of the web page. Right: the Google Chrome developer console.
In this case the word “hero” appears in several places in the code for our area of an image with text overlay. If you look for the main element, i.e. the code container that encloses the whole area, you’ll see “type”:”hero” in the code – so the “type” of the section is “hero”. With this knowledge we can now find our way around the Shopify code. (If you use a different browser that doesn’t have this feature, you can also go directly into the code, click through the Liquid files under “Sections” and use Ctrl+F/Cmd+F to search for the name of the section you want to edit)
Make the change in the code to enable HTML and CSS for the text field
Open your theme’s code by clicking “Actions” (or “Aktionen”) and selecting “Edit code” (or “Code bearbeiten”):

This is how you get to your theme’s code.
There, among the “Sections” files, look for the name you found in the code, i.e. “hero.liquid” in our example. Click on the file and press the key combination “Ctrl + F” (or “Cmd + F” if you use a Mac) to open a search field. If you want to make sure you’re editing the file for the right section, simply search for “{% schema %}” without quotation marks. Directly below it you’ll find code containing the name of the section:

The German name of the section this Liquid file belongs to can be seen here in line 131: “Foto mit überlegtem Text” (“Image with text overlay”)
Now enter “richtext” in the search field. Here you can see that the value “Text” appears under “label” – that’s the heading shown above the text field in the editor. If you get a match with a different value for “label”, search again until you’ve found this spot.

This is the part you need to change to be able to use HTML and CSS in the text field of the “hero” section.
Now change the value “richtext” to “textarea” and click “Save”.

“richtext” has been replaced by “textarea”. Don’t forget to save!
Done. If you now go back into the editor and edit the corresponding section, you’ll see formatting through HTML and CSS in the text field and can use it yourself to design the text as you wish:

Here “style=background-color:red” was used to give the text a red background.
A quick summary once more:
Find out which Liquid file belongs to the section you want to edit
Search this file for the code for the text field
In the code, change the type of the text field from richtext to textarea
Save your change in the code – you can now use HTML and CSS in the corresponding text field
By the way, at https://www.w3schools.com/html/default.asp you’ll find numerous tutorials, resources and examples on using HTML and CSS.
If you have any further questions about this post or need other help setting up your online shop, get in touch with us and we’ll be happy to help! 🙂
Happy Clicking & Coding,
your sorcerer’s apprentice Jonathan McGrinsey


