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 48367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:16:08+00:00 2026-05-10T16:16:08+00:00

Possible Duplicate: Avoiding repeated constants in CSS We have some theme colors that are

  • 0

Possible Duplicate:
Avoiding repeated constants in CSS

We have some ‘theme colors’ that are reused in our CSS sheet.

Is there a way to set a variable and then reuse it?

E.g.

.css OurColor: Blue  H1 {   color:OurColor; } 
  • 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. 2026-05-10T16:16:08+00:00Added an answer on May 10, 2026 at 4:16 pm

    There’s no requirement that all styles for a selector reside in a single rule, and a single rule can apply to multiple selectors… so flip it around:

    /* Theme color: text */ H1, P, TABLE, UL { color: blue; }  /* Theme color: emphasis */ B, I, STRONG, EM { color: #00006F; }  /* ... */  /* Theme font: header */ H1, H2, H3, H4, H5, H6 { font-family: Comic Sans MS; }  /* ... */  /* H1-specific styles */ H1 {     font-size: 2em;     margin-bottom: 1em; } 

    This way, you avoid repeating styles that are conceptually the same, while also making it clear which parts of the document they affect.

    Note the emphasis on ‘conceptually’ in that last sentence… This just came up in the comments, so I’m gonna expand on it a bit, since I’ve seen people making this same mistake over and over again for years – predating even the existence of CSS: two attributes sharing the same value does not necessarily mean they represent the same concept. The sky may appear red in the evening, and so do tomatoes – but the sky and the tomato are not red for the same reason, and their colors will vary over time independently. By the same token, just because you happen to have two elements in your stylesheet that are given the same color, or size or positioning does not mean they will always share these values. A naive designer who uses grouping (as described here) or a variable processor such as SASS or LESS to avoid value repetition risks making future changes to styling incredibly error-prone; always focus on the contextual meaning of styles when looking to reduce repetition, ignoring their current values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 188k
  • Answers 188k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Definitely Regular expressions: Dim myPattern As String = "<U>(.*?)</U>" For… May 12, 2026 at 5:38 pm
  • Editorial Team
    Editorial Team added an answer You need to turn off DirectDraw -- see http://tiredblogger.wordpress.com/2009/05/29/configuring-oracle-sql-developer-for-windows-7/, specifically… May 12, 2026 at 5:38 pm
  • Editorial Team
    Editorial Team added an answer The reason Java (and C#/.NET) is not a viable option… May 12, 2026 at 5:38 pm

Related Questions

Possible Duplicate: Avoiding repeated constants in CSS I want to include a class within
Possible Duplicate: C# member variable initialization; best practice? Is there any benefit to this:
Possible Duplicates: Gracefully avoiding NullPointerException in Java Multilingual fields in DB tables Exact duplicate
I am trying to make use of the yahoo exceptional performance rule : avoiding

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.