Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9284947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:01:46+00:00 2026-06-18T19:01:46+00:00

I’ve just read Scalable and Modular Architecture for CSS and it’s got me thinking

  • 0

I’ve just read Scalable and Modular Architecture for CSS and it’s got me thinking about a few things. Snook’s two principle tennets are:

  1. Increase the semantic value of a section of HTML and content
  2. Decrease the expectation of a specific HTML structure

So this means using semantic class names rather than relying on unsemantic element types for targeting. For example rather than targeting .someClass h5, I might target .someClass-title instead so that if the h5 is swapped out for something else, things don’t break.

Personally I find encoding an element’s hierarchy in its name kind of unpleasant (even if it is semantically correct). I would prefer doing .someClass .title. But to use a class as generic as title you need to accept that this class will be used in lots of different contexts.

So is there anything wrong with using the same class in completely different contexts if I know it will be namespaced by a previous item in the selector?

For example say I have three different places in my site where a class of ‘title’ makes sense:

HTML

<header class="pageHeader">
   <h1 class="title">Some Title</h1>
</header>

...

<article class="leadArticle>
   <h3 class="title">Some Article Title</h3>
</article>

...

<ul class="productPreviews">
   <li class="product">
      <h5 class="title">Some Product Name</h5>
   </li>
</ul>

CSS

.pageHeader .title
{

}

.leadArticle .title
{

}

.productPreview .product .title
{

}

Edit: as Alohci mentions in his answer below, a header tag isn’t unsemantic, so perhaps this wasn’t the best example to use.

Obviously I might be doing something completely different to the title in these contexts, but title makes absolute sense with it’s module’s namespace, and I never have any intention of using title as a general selector.

This seems to tick all the boxes. It is semantically rich, completely decoupled from implementation. For example if the last example was changed into an ol or a stack of divs, nothing would break, and if title was wrapped in a div it would still be targeted.

This makes sense to me, but I haven’t seen this approach used much and I’m wondering why. An obvious disadvantage is that you are chaining classes in the selector, but I think this is preferable to namespacing each classname.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T19:01:48+00:00Added an answer on June 18, 2026 at 7:01 pm

    I prefer using a class like .title rather than selecting just the h5 element, as I feel it decouples the HTML from the CSS some more. If, for whatever reason, you decide an h4 or and h6 is more appropriate for the document outline, or some other element/reason, you would have to refactor your CSS if you are selecting the element(h5) vs select a class(.title).

    This is why I prefer to class ALL THE THINGS vs. element selectors because the markup may change over time. If your working on a smaller site that isn’t seeing many updates, this may not be a concern, though it’s good to be aware of.

    As far as if there is anything wrong with using the same class in completely different contexts if you know it will be namespaced by a previous item in the selector, I have mixed thoughts on it.

    On one side, some concerns come to mind, for instance the use/meaning/role of .title could be empty without it’s parent selector. (.pageHeader .title) While I think that .title is a perfectly fine class name, it may be difficult for other devs to understand it’s meaning comes from a parent selector like .pageHeader .title

    Another concern is if you are using the class .title for multiple instances of “titles” in a module, you can run into issues. The basic idea is that the local scoping descendant selectors provide can sometimes be too restricting if trying to stretch the reusability of .title within the module. I set up a code demo to show what I’m talking about here.

    On the other side, descendant selectors are one of the most used selectors, specifically for their scoping purpose.

    Tim Murtaugh, who is one of the developers (not sure if he is the lead dev or not) for A List Apart uses descendant selectors for the majority of his styles on his personal site.

    I’ve recently been exploring this and BEM and would agree with your conclusion, “this is preferable to namespacing each classname.”

    I prefer .pageHeader .title{…} vs. .pageHeader__title{…} but there are always instances where one approach may be more beneficial in a situation over the other.

    As with most things, it depends, but I think if you don’t let the nesting go too deep and are thoughtful with how you use them, descendant selectors are powerful and good solution for providing locally scoped styles while also offering a solution for globally scoping styles.

    For example:

    /* Globally scoped styles for all .title(s) */
    .title{
       font-family: serif;
       font-weight: bold;
    }
    
    /* Locally scoped styles for individual .title(s) */
    .pageHeader .title {
        color: #f00;
    }
    
    .leadArticle .title {
        color: #00f;
    }
    
    .productPreview .product .title {
       color: #0f0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
i got an object with contents of html markup in it, for example: string
I have two tables with like below codes: Table: Accounts id | username |
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.