January 19, 2024

Webflow Class Naming Conventions: The In-Depth Comparison

Hedrick logo
Hedrick
@hedrickagency

Behind every well-structured and scalable website lies a crucial element: class naming conventions. Class naming conventions can make or break how easy your code is to maintain, and can make it a lot more difficult for your developers to collaborate. 🤔

If your Webflow projects are often complex and require frequent updates, CSS naming conventions provide a solid foundation for efficient teamwork and long-term code sustainability.

That’s why in this blog post, we’ll be diving into all things Webflow class naming conventions and exploring some popular approaches. Read on for valuable insights into getting your class names right! 

Understanding Class Naming Conventions

✨"Class naming conventions"✨ What exactly are they, and why do they matter in CSS? Let's break it down and shed some light on the importance of using consistent class names.

What is a class naming convention?

Class naming conventions are a set of rules for developers to follow when naming HTML elements in CSS. They provide a standardized way to identify and organize elements in your code. They basically bring order to code chaos by sorting components by type. 

What are the benefits of using class naming conventions? 

There are a lot of benefits to using standardized class names, but the key benefit here is clarity. When you name your classes consistently throughout your project, you’re essentially giving each element a clear label. You and other developers can quickly understand what each element represents and how it should behave. Think of it as a well-organized filing system for your code. 👍

But it doesn't stop there. CSS naming conventions play a huge role in maintaining and scaling your projects. ⬇️

As your website or app grows, it becomes more complex. Without a structured naming approach, you'll find yourself lost in a sea of code. Consistent and meaningful class names make it easier to maintain your project over time, especially when multiple developers are involved.

Scalability is another big factor. With a proper naming convention in place, you can add new features or components to your project without breaking a sweat. The organized and modular nature of class naming conventions allows you to reuse code and quickly implement changes without disrupting the entire codebase. 

So, what is the best approach to class naming conventions? Let’s find out! 👇

The Full Comparison of Class Naming Conventions

1. Client-first by Finsweet

The "Client-first" convention by Finsweet focuses on improving code organization by using client-specific names.

With the Client-first convention, you'll find a clear separation of structure, style, and behavior. This makes it easier to understand and modify your code as your project evolves. It also does wonders for simplicity and ease of use, which can be a real time-saver when you're working on tight deadlines.

The Client-first convention is quickly becoming the standard for Webflow development. Many developers are embracing this approach and finding success with it. Additionally, it plays nicely with tools like Relume, making your development process even smoother.

❌ However, every convention has its cons too. One drawback of the Client-first convention is that you may end up with a lot of elements to create a simple structure. This compares to using multiple puzzle pieces when you could've achieved the same result with just one. You might end up with a larger DOM size, which can impact performance if not managed properly.

Another thing to keep in mind is the name itself: "Client First." While it sounds empowering for clients, it doesn't always mean they have the expertise to navigate the designer and make informed decisions. They might feel like they know what they’re doing, but often, it’s not the case and you end up with an unnecessary mess. 

2. MAST by No-Code Supply

MAST by No-Code Supply takes a modular approach, focusing on easy reusability of code components. 

With MAST, you'll find atomic class names that provide precise control and customization options. This level of granularity allows you to fine-tune your elements with ease. ✅

One of the standout features of MAST is its consistency in naming across different elements. This means that similar components will have consistent class names, making it intuitive and easy to understand the structure of your code.

MAST is inspired by Bootstrap and Tailwind CSS (which are developer-friendly frameworks) and is light-weight, utility-first, and uses a responsive design approach within Webflow. Unlike Finsweet's Client-First convention, MAST opts for abbreviated classes, keeping the framework lighter, easier to read, and more manageable. This approach makes project development in Webflow quicker and more efficient.

MAST’s modular approach promotes code reusability. You can create components that are easily repurposed throughout your project, saving you time and effort in the long run. Plus, it provides a level of consistency that ensures a cohesive design across your website.

❌ MAST also has its cons though. One potential drawback is that the atomic class names can become quite extensive. While it offers precision, it can also make your codebase a bit longer and potentially harder to manage.

Additionally, while consistency is a strength of MAST, it can also be a limitation. If you prefer more flexibility and variation in your design, the strict consistency enforced by MAST may feel restrictive at times.

3. Lumos by T.Ricks

The name of this class-naming convention makes a lot of sense. Lumos takes a unique approach by using a Nested Utility Class Approach and some cool light and dark styling to help you organize your classes.

With Lumos, you'll find a clever use of light and dark classes to create different visual themes. This approach allows for easy customization and theming, giving your website a distinct and cohesive look.

One of the strengths of Lumos lies in its semantic class names. Semantic class names provide an intuitive understanding of the purpose and style of each element. This feels like using descriptive labels that immediately convey the intended meaning, making your code more readable and maintainable.

Lumos utilizes a Nested Utility Class Approach, which enhances efficiency, flexibility, and consistency in managing styles within Webflow. Instead of applying individual utility classes to elements, Lumos lets you group utilities under a single class. You can then apply this composite class to elements, ensuring consistent styling. Moreover, changes made to this class cascade across all elements using it, simplifying edits.

A significant advantage of this approach is that it completely eliminates the problems often encountered when using combo classes in Webflow. Combo classes can quickly become convoluted and difficult to manage, but Lumos simplifies the process by using separate light and dark classes for styling. This makes styling elements a breeze, promoting a smooth and streamlined development experience.

❌ However, a notable drawback of Lumos is that everything is styled inside an HTML embed. While this allows for greater customization, it also means that it's not as "no-code" as other conventions. This can be a challenge when working with a team where not everyone has the same level of experience or understanding of CSS variables and properties. Collaboration might become tricky if team members are not comfortable working with embedded code.

4. Knockout by Edgar Allan

Knockout focuses on using meaningful and expressive class names to enhance code clarity. It creates class names that convey the purpose and function of each element. This approach makes your code more readable and easier to understand for both yourself and other developers.

Another strength of Knockout is its use of prefixes for clear categorization. When you are able to add specific prefixes to your class names, you create a visual hierarchy and structure within your code. It's similar to labeling different sections of a book, making it easier to navigate and maintain.

Consistency in naming conventions is also a key aspect of Knockout. Following a consistent naming pattern throughout your codebase means that you ensure that elements with similar functionalities have similar class names. This consistency improves maintainability, as you can easily locate and modify related elements when necessary.

The meaningful and expressive class names in the Knockout method make your code more self-documenting. You can understand the purpose and behavior of elements just by looking at their class names, which will save you time and reduce confusion down the line.

The use of prefixes for categorization also brings clarity to your code and improves code structure, allowing for easier navigation when working on large projects.

❌ One potential drawback of Knockout is that it requires discipline and attention to detail to maintain consistency throughout the codebase. It might take some extra effort to ensure that all class names align with the convention, especially in larger projects with multiple developers.

5. Webflow’s Standard Class Naming Convention

While Webflow provides a default naming convention, there are some pros and cons you need to consider before fully embracing it. 

One aspect to consider is that Webflow classes tend to have less descriptive class names compared to other conventions out there. Instead of using highly specific and expressive names, the standard convention often uses more generic terms. This can make it a bit harder to understand the purpose and functionality of elements just by looking at their class names.

Another consideration is the limited organization and structure in class naming. The standard convention doesn’t really provide a sufficiently comprehensive system for categorizing and organizing classes. Without clear naming guidelines, it can become challenging to navigate and maintain your codebase, especially as your project grows in complexity.

The less descriptive class names can make your code less self-explanatory and harder to decipher, especially for developers who are new to the project. The limited organization and structure might lead to confusion and difficulties when trying to locate and modify specific elements. And the lack of flexibility for customization and theming can be a hindrance if you have unique design requirements or if you want to create a cohesive visual style throughout your project.

Flexibility for customization and theming is another area where the standard convention falls short. It may not offer the same level of customization options as other conventions. If you're aiming for a highly tailored design or if you need to create consistent themes throughout your project, you might find the standard convention limiting in that regard.

The main advantage of Webflow’s standard class naming convention is that it's a standard. This means that if you stick to it, your code will align with the default behaviors and updates of the Webflow platform. It tends to provide a sense of familiarity and ease when working within the Webflow environment. 👍

6. The BEM (Block, Element, Modifier) Naming Method

The final class naming convention we’ll be discussing today is the BEM – the Block, Element, Modifier naming method. BEM is not a tool or library, but rather a methodology designed to structure CSS class names in a standardized way, leading to more maintainable and scalable codebases.

The purpose of BEM is simple yet powerful: it aims to provide a structured approach to naming conventions, ensuring better organization and clarity in HTML and CSS structure. It breaks down the user interface into Blocks, Elements within those blocks, and Modifiers to denote variations. 

BEM naming convention examples

For example, you might have a block called card, an element within that block called title, and a modifier for a specific variation like card__title--highlighted. This systematic approach helps developers understand the purpose and relationships of different elements at a glance.

BEM primarily targets developers focusing on HTML and CSS architecture. It provides a framework for consistent and meaningful class names, making it easier to collaborate and maintain projects over time. 

It's worth noting that many developers combine BEM with utility-first frameworks like Tailwind CSS or even Client-First style guides. This combination allows them to leverage the benefits of a structured naming convention while also taking advantage of the speed and efficiency of utility classes.

➡️ When using BEM with Tailwind CSS, developers can enjoy the best of both worlds. You can use Tailwind's utility classes for rapid development and styling, while still maintaining a structured and semantic naming convention through BEM. 

For example, while building a button (a block), you can use Tailwind utilities for styling, but any custom classes or components can follow the BEM structure like button__label--active.

This combination caters especially well if you want to rapidly prototype and build while maintaining a clear and structured relationship between HTML and CSS. BEM ensures the codebase remains organized and maintainable, while utility-first frameworks like Tailwind CSS streamline the development process.

Best Practices: How to Choose Webflow Class Naming Conventions

Choosing the right class naming convention in Webflow can have tremendous impact on your code’s readability, ease of collaboration, and maintainability. Here are some best practices to consider when making this decision 👇

Readability, ease of use, and flexibility

Consider whether it is easy to understand and work with the naming convention. Opt for conventions that use clear and descriptive class names, making it easier for developers to comprehend the purpose and functionality of each element. 

Additionally, look for conventions that provide flexibility in customizing and theming in order to meet the specific requirements of your project.

Collaboration and code maintenance

Think about how the chosen naming convention will impact collaboration among team members. Choose a convention that promotes consistency and clarity, allowing developers to easily navigate and modify the codebase. 

Consistent naming conventions foster better teamwork and reduce the likelihood of confusion or conflicts when multiple developers are working on the same project.

Implementing and enforcing a consistent naming convention

Once you've chosen a naming convention, it's important to establish guidelines and enforce their usage. Consistency is key to maintaining a clean and structured codebase. ✅

Create a style guide or documentation that outlines the conventions, naming patterns, and any specific rules to follow. Regularly communicate and educate the development team on the importance of adhering to the agreed-upon naming convention.

Documentation and communication

Documentation is essential for maintaining code consistency and enabling smooth collaboration. Clearly document the chosen naming convention, including examples and explanations of how it should be applied. 

This documentation serves as a reference for developers and ensures everyone is on the same page. Enable open communication within the development team, encouraging discussions and feedback on the chosen convention to continually improve and refine the naming practices.

FAQ – Frequently Asked Questions

What approach do you use for class naming in Webflow?

In Webflow, developers employ various approaches for class naming based on their preferences and project requirements. You can choose from a wide range of established conventions like BEM (Block, Element, Modifier), Client-First, MAST, Lumos and many more! At Hedrick, we use Client-first because it is becoming the standard for Webflow development!

What is the best naming convention for CSS class?

Determining the best naming convention for CSS classes depends on many factors like how complex your project is and what degree of team collaboration it requires. Although you’ll likely want to go for popular conventions like Client-first because they are widely recognized for their ability to enhance maintainability and scalability.

What is the best naming convention for HTML classes?

For HTML classes, the best naming convention often aligns with CSS naming conventions. BEM, which provides a structured approach to naming classes, is widely adopted for HTML elements in conjunction with CSS styling.

What is the BEM naming convention?

The BEM (Block, Element, Modifier) naming convention is a widely used methodology for structuring CSS class names. It breaks down the user interface into blocks (standalone components), elements (parts within blocks), and modifiers (variations or states).

How do you write a BEM class correctly?

To write a BEM class correctly, developers typically start with the block name, followed by a double underscore (__), and then the element name. Modifiers, if needed, are appended with a double dash (--) and the modifier name. For example, ".block__element--modifier" represents a BEM class structure.

Do people still use BEM?

Yes, BEM continues to be widely used in the web development community. Many developers and teams appreciate its structured approach and the benefits it brings to code organization and scalability.

What are the 3 things to consider in establishing a naming convention?

When establishing a naming convention, three key factors to consider are clarity, consistency, and relevance. Names should be clear and descriptive, follow a consistent pattern throughout the codebase, and be relevant to the purpose and functionality of the elements they represent.

What naming conventions should be avoided?

Naming conventions that lack clarity or rely on cryptic or ambiguous terms should be avoided. It's important to prioritize readability and choose conventions that enhance code comprehension.

Hedrick logo
Hey, here's a tip from Hedrick!

At Hedrick, we use Finsweet's Client-first class naming convention because it is becoming the standard for Webflow development, and is utilized by popular development tools and resources like Relume Library.

Hourly Webflow development

Hire Hedrick, Your Webflow Sidekick

Whether it's developing new websites and landing pages, building complex animations, integrating apps, or adding some custom code – if it's related to your Webflow site, we can help!

Book a 1-on-1 call with a Webflow Expert on our team to fix a bug, find a solution, or help you build something in Webflow!

Our hourly pricing has been sent to your inbox.
Oops! Something went wrong while submitting the form.
Free

The Webflow Toolkit