Is it possible to define custom colors in html and use them in a css

I want to define a custom color and use it in my css
such as


where myhighlightcolor can be a color which I choose.Is it possible to do this in html or css ?If yes, then where do i define the color?

Who is Participating?
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
If you are wanting 'myhighlightcolor' to be a variable that you can change in one place and use in many, then you will need to use a programming language like Javascript, ASP, or PHP.  HTML and CSS are 'description' languages but not programming languages but you can use programming languages to alter the HTML and CSS that is generated.
You should do this with Javascript or PHP.
I would use javascript for changing the class
more on this

if you spend sometimes with jQuery framework - it will be a lot easier in the future
You've pretty much answered your own question, in your stylesheet define:
    background:#ffcc00;/*or your own color*/

Then set the class of the tag that surrounds the text to be highlighted for example:
<span class="highlightedtext">blah blah</span>

No need to resort to PHP or JavaScript

res_thisAuthor Commented:
not clear
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.