Skip to content

CSS best practices for business websites

Updated on:
Updated by: Ciaran Connolly

CSS best practices are the habits that make using CSS on a business website fast to load and safe to change: one external stylesheet, first-screen styles loaded early, unused code removed and a cascade that stays readable. ProfileTree checks each of these when it builds or reviews a WordPress site, because slow, tangled CSS costs visitors and developer time.

What CSS controls on a business website

CSS (Cascading Style Sheets) is the code that tells a browser how each part of a page should look. HTML holds the content and its structure, while CSS sets the presentation, from layout, spacing, colour and typefaces to the way a page rearranges itself on a phone. JavaScript sits alongside both and adds behaviour such as menus and forms.

For a business owner, CSS matters for two practical reasons. It decides whether the site looks right on every screen your customers use, and the way it is written and loaded affects how quickly those customers see anything at all. A site can have excellent copy and still lose visitors if the stylesheet holds the page back for a few seconds on a mobile connection.

Each CSS rule has two parts. The selector picks out the elements to style, such as every main heading or every button with a particular class, and the declaration block lists the properties to change and their values. A browser quietly ignores a declaration it cannot read, so a single typo can make a style vanish without any error message, which is why so many “broken” layouts turn out to be malformed code.

ProfileTree is a Belfast web design and digital marketing agency, founded in 2011 and based at the McSweeney Centre, and stylesheet structure is part of every project in our WordPress web design work. The practices below are the ones a business owner can ask a developer about, or check for themselves, without needing to write the code.

Three ways to add CSS to a page

There are three ways to attach CSS to a page, and each suits a different job. Choosing the wrong one does not usually break a site, but it can make it slower to load and harder to change.

External stylesheets for multi-page sites

An external stylesheet is a separate .css file that every page links to from its head. One file controls the look of the whole site, so changing a brand colour or a heading size across fifty pages means editing a single value in a single place.

External files also suit caching (storing a copy of a file so the browser does not download it again). A returning visitor, or someone moving from your homepage to a service page, reuses the copy already saved in their browser, and the page appears sooner. Server-level caching adds to this, and it is part of what our hosting and maintenance plans look after.

Internal CSS for one-off landing pages

Internal CSS sits inside a style element in the head of one page and applies only to that page. It suits a single campaign landing page with styling nothing else on the site shares, and it saves the browser a separate file request.

The drawback appears as soon as the page is copied. Five landing pages with five sets of internal styles means five places to update every time the brand changes, and the copies drift apart within months.

Inline CSS for HTML email

Inline CSS is written into the style attribute of a single element. It overrides almost every other rule, mixes presentation into the content and makes later changes slow, so on a website it belongs only in rare, deliberate exceptions.

HTML email is the main place where inline styles are the right answer. Several email programs have a history of ignoring or stripping styles placed in the head of a message, so email templates usually have their CSS moved inline automatically before sending. If your newsletters look different in different inboxes, this is often the reason.

SituationMethodReason
A website with more than one pageExternal stylesheetOne file to maintain, and browsers can cache it
A single campaign landing pageInternal CSSNo extra file request, and the styles are not shared
An HTML email or newsletterInline CSSEmail programs handle head styles unreliably
A one-off override on one elementInline CSS, sparinglyA deliberate exception that is documented
A WordPress siteThe theme’s external stylesheet, or a child themeSurvives theme updates and caches well

How CSS affects page speed and SEO

CSS affects search visibility through speed and stability, and the effect runs through Core Web Vitals (Google’s measures of loading speed, responsiveness and visual stability). Google’s page experience documentation confirms that its ranking systems use Core Web Vitals. It also says that good scores do not guarantee top positions, and that relevant content will still be shown when a page’s experience is poor. Speed work supports a page that already answers the searcher well; it will not rescue one that does not.

Render-blocking stylesheets and Largest Contentful Paint

By default, a stylesheet linked in the head is render-blocking, which means the browser will not draw the page until it has downloaded and processed that file. On a fast office connection, the delay is barely noticeable. On a weak mobile signal, a large stylesheet can leave visitors looking at a blank screen.

That delay feeds directly into Largest Contentful Paint, the Core Web Vitals measure of how long the largest visible element (usually a hero image or the main heading) takes to appear. A single stylesheet carrying the styles for the whole site, linked from the head of each page, pushes that moment back. Our guide to how Core Web Vitals are measured explains the thresholds and where to find your own figures.

Critical CSS for the first screen

Critical CSS is the small set of styles needed to draw what a visitor sees before scrolling. The technique places those styles directly in the page head and loads the rest of the stylesheet in the background, so the first screen appears styled while the remaining rules arrive. Google’s developer site web.dev describes the method in its guide to deferring non-critical CSS, including how to find the critical styles with the Coverage panel in Chrome’s developer tools.

The same guide calls this an advanced technique that can introduce bugs if done badly, and notes that most sites reach the recommended speed targets without it. That matches our experience: removing what the site does not need usually comes first, and critical CSS is worth the effort on high-value pages such as service and landing pages once the basics are in place.

Minifying and removing unused CSS

Minifying a stylesheet strips out the spaces, line breaks, and comments that people need for reading the code and that browsers do not. Every mainstream WordPress performance plugin and build tool can do this, so there is little reason for a live site to serve an unminified file.

Unused CSS is usually the bigger problem. Many WordPress themes and page builders load styles for sliders and galleries a site never uses, and every visitor downloads that dead weight on each visit. The Coverage panel in Chrome shows what share of a stylesheet a page actually uses, and our WordPress speed optimisation guide sets out the order in which to tackle fixes like this one.

Layout shift and the space a page reserves

Cumulative Layout Shift measures how much content jumps around while a page loads, such as a button moving just as someone goes to tap it. CSS prevents most of this by reserving space before the content arrives. That means giving images and video embeds a width and height, or an aspect ratio, and setting a minimum height for banners and cookie notices that load late. A stable page is easier to use and scores better on the stability measure.

Writing CSS that stays easy to maintain

Maintainable CSS is cheaper to own, because every change takes a developer minutes and nothing breaks elsewhere on the site. Most stylesheets that become expensive to change got there through a misunderstood cascade and a growing pile of overrides.

How the cascade and specificity decide which rule wins

When two rules target the same element, the browser picks a winner using specificity, a score based on the selectors in each rule. MDN’s reference on specificity counts three columns: ID selectors first, then classes, attributes and pseudo-classes, then element types. The columns are compared from left to right, so a single ID outweighs any number of classes, and where two rules score the same, the one written later wins.

Styles written straight onto an element beat all of these. That is one more reason inline styles cause trouble on websites: the next developer adds a stylesheet rule, nothing changes on screen, and time disappears in looking for the cause.

Why overusing important creates problems later

Adding the important flag to a declaration forces it to apply over normal rules. It fixes the immediate problem and creates a bigger one, because the only way to override an important declaration is another important declaration with a higher score. MDN advises solving conflicts with specificity first and keeping the flag for extreme cases, such as overriding styles from a third-party plugin you cannot edit.

A quick search of your theme’s stylesheet for the word “important” tells you a lot about its health. A handful of uses is normal. Hundreds suggest the code has been patched for years, and each future change will cost more.

Mobile-first media queries

Media queries let a stylesheet apply different rules at different screen widths. Writing mobile first means the default styles are for small screens, and larger layouts are added with minimum-width queries as the screen grows. The approach usually produces less code and leaves phones with fewer rules to process, which suits a search engine that assesses the mobile version of your site.

Why CSS changes sometimes do not show

When a style refuses to appear, the cause is almost always one of a short list of predictable problems. Opening the browser’s developer tools and inspecting the element shows which rules apply and which are crossed out, and that view settles most cases in minutes.

  • A rule with higher specificity elsewhere is overriding the new one, and it appears crossed out in the inspector.
  • A typo in a property name or value has made the browser discard the declaration silently.
  • The browser, a caching plugin or the server is still serving an old copy of the stylesheet, so the change needs a cache clear or a hard refresh.
  • The selector targets the wrong thing, for example, a class selector written for an element that carries an ID.

Choosing between a framework and native CSS

A CSS framework is a ready-made library of styles and layout tools, and whether you need one depends on the kind of site you are building. For most SME brochure and service websites, well-organised native CSS is enough.

Bootstrap for fast, standard layouts

Bootstrap provides pre-built components such as navigation bars and cards, along with a twelve-column grid. It suits internal tools and prototypes, where speed of delivery matters above a distinctive look. Sites built on it tend to look alike unless the defaults are heavily customised, and it ships styles for components a small site may never use.

Tailwind CSS for component-based builds

Tailwind CSS takes a different approach, offering small single-purpose classes that developers combine in the HTML. Its build process removes the classes a site does not use, so the final stylesheet stays small. It is popular for web applications built in JavaScript frameworks such as React, where the page is assembled from reusable components.

When native CSS is enough

Current browsers support features that once needed a framework or a preprocessor (a tool that compiles an extended language into standard CSS). These include custom properties for storing values such as brand colours, nesting, CSS Grid for layout, container queries and the: has() selector. A marketing site with a clear design system can be built cleanly with these alone. Before adding a framework to a project, it is worth asking your developer what it will do that native CSS cannot.

CSS on WordPress websites

On WordPress, the rule that matters most is never to edit the parent theme’s files directly, because a theme update overwrites them and your changes disappear. Larger changes belong in a child theme, a small theme that inherits everything from the parent and holds your own styles separately. Small adjustments can go in the Additional CSS panel, found in the Customiser on classic themes and in the Site Editor styles on block themes.

Page builders such as Elementor and the block editor each add their own stylesheets, and these can clash with the theme’s rules in ways that confuse anyone new to the platform. When a site has been through several builders or themes over the years, leftover styles from each one often load across the whole site. A clean-up of this kind is one of the quickest speed gains on an older WordPress site, and it pairs well with the HTML structure advice in our article on building a fast site with HTML and CSS.

“A website is a business tool before it is anything else, and its stylesheet is part of that tool. At ProfileTree we build on WordPress because a Belfast business has to be able to run its own site once we hand it over, and because every part of it can be measured, including how quickly the CSS lets each page appear. The sites that keep earning are the ones the owner still uses every week.” Ciaran Connolly, founder of ProfileTree

Getting a speed and Using CSS review of your website

The first step is to run your most important pages through Google’s PageSpeed Insights and look for warnings about render-blocking resources and unused CSS. If those warnings appear on your homepage and main service pages, the stylesheet is worth fixing before any redesign or cosmetic change.

Our website development team handles this kind of work on WordPress sites, from removing unused styles to rebuilding a theme that has been patched for years. Development work is charged hourly, and putting a neglected site back in order typically costs between £800 and £2,000 plus VAT, depending on what the review finds.

FAQs

What are the effective CSS rules for SEO?

No CSS rule improves rankings on its own, but several protect the speed and stability that Google’s systems measure. Load one minified external stylesheet, remove styles the site does not use, reserve space for images and embeds so content does not jump, and use readable font sizes on mobile. Avoid hiding text with CSS purely to place keywords on the page, because hidden content written for search engines works against you. Relevant, useful content still matters far more than any stylesheet change.

Does CSS affect page speed and rankings?

Yes, CSS affects page speed directly and rankings indirectly. A large stylesheet in the page head delays the moment the browser can draw anything, which slows Largest Contentful Paint, and poorly sized elements cause layout shift. Google uses Core Web Vitals in its ranking systems but states that good scores do not guarantee top positions, so treat CSS fixes as support for strong content.

Should I use inline, internal or external CSS?

Use an external stylesheet for any website with more than one page, because it is easier to maintain and browsers can cache it. Internal CSS suits a single landing page with unique styling. Inline CSS belongs in HTML email, where many email programs handle other methods unreliably, and only as a rare documented exception on a website.

Why is my CSS not applying to an element?

The usual cause is a more specific rule elsewhere overriding yours. Inspect the element in your browser’s developer tools and look for your declaration crossed out. If it is missing altogether, check the property name for a typo and confirm the selector matches the element’s class or ID. Clearing the caching plugin and the browser cache rules out an old copy of the stylesheet.

Leave a comment

Your email address will not be published.Required fields are marked *

Web Design

Web Design

We design stunning, user focused websites that present your brand beautifully and convert visitors into customers.

Web Development

Web Development

We use the latest development tools to build websites that are optimised for peak performance at all times.

Website Management

Website Hosting

We manage everything from site updates and reports to hosting, allowing you to focus on running your business.

Search Engine Optimisation

Search Engine Optimisation

Using the latest SEO techniques, we help your brand get found for the right terms and by the right people.

Digital Marketing Strategy

Digital Marketing Strategy

Navigate the digital landscape with a marketing strategy. Our team crafts comprehensive plans that resonate with your target audience, drive engagement, and boost conversions.

Digital Marketing Training

Digital Marketing Training

Elevate your digital proficiency. Our in-depth training sessions equip your business with cutting-edge digital marketing techniques to outperform competitors and thrive online.

Social Media Strategy

Social Media Strategy

Captivate and grow your social following. We create tailored social media strategies that ignite engagement, amplify your brand's online presence, and foster lasting connections.

Email Marketing Solutions

Email Marketing Solutions

Harness the power of your mailing list. Our precision-targeted email marketing campaigns are engineered to nurture relationships and drive tangible business outcomes.

Content Marketing Services

Content Marketing Services

Elevate your brand with our content marketing mastery. From thought-provoking blogs to eye-catching infographics, we craft content that captivates, informs, and converts your ideal audience.

Video Production

Video Production

Capture your audience with compelling video content. Our production team creates visual stories that engage, inform, and leave a lasting impression.

Brand Storytelling

Brand Storytelling

Bring your brand's story to life with authenticity. We craft compelling narratives that strike a chord with your audience, forging a powerful emotional bond with your brand.

Content Strategy Development

Content Strategy Development

Strategic content that drives action. We develop content strategies that align with your business goals, ensuring every piece of content counts.

AI Training

AI Training

Empower your business with AI expertise. Our tailored training demystifies AI, equipping your team with the knowledge to leverage its potential for growth and innovation.

AI Chatbots

AI Chatbots

Transform customer service with AI chatbots. We develop sophisticated chatbots that elevate user experience, streamline interactions, and deliver unparalleled efficiency.

AI Marketing

AI Marketing

Transform your reach with AI-driven marketing. Harness data-driven insights for laser-targeted campaigns that captivate, engage, and convert your audience.

AI Tools for Business

AI Tools for Business

Optimise your operations with cutting-edge AI tools. We integrate intelligent solutions that streamline processes, enhance efficiency, and support data-driven decision-making.

Join Our Mailing List

Grow your business with expert web design, AI strategies and digital marketing tips straight to your inbox. Subscribe to our newsletter.