Solved

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

Posted on 2011-03-03
5
153 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add image to into animation on website template 1 27
Changing way home page shows 2 30
Html test in IIS 4 20
How do I pull the base url for use in html links 7 23
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
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 videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to dynamically set the form action using jQuery.

776 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