Solved

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

Posted on 2011-03-03
5
152 Views
Last Modified: 2012-05-11
I want to define a custom color and use it in my css
such as

.highlightedtext{
backgroundcolor:myhighlightcolor;
}

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?

0
Comment
Question by:res_this
5 Comments
 
LVL 4

Expert Comment

by:mars-vie
ID: 35029039
You should do this with Javascript or PHP.
0
 
LVL 7

Expert Comment

by:dxdinh
ID: 35029141
I would use javascript for changing the class
more on this
http://stackoverflow.com/questions/195951/change-an-elements-css-class-with-javascript

if you spend sometimes with jQuery framework - it will be a lot easier in the future
http://docs.jquery.com/Tutorials
0
 
LVL 2

Expert Comment

by:nedlogan
ID: 35029554
Hi,
You've pretty much answered your own question, in your stylesheet define:
.highlightedtext{
    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

Regards.
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 35029903
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.
0
 

Author Closing Comment

by:res_this
ID: 37503775
not clear
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now