Textbox highlight color html

Does anyone know how to change the highlight color in a textbox on a webpage ?  Standard highlight colors are dark blue background and white text.  I would like to be able to modify these if possible.
cannonarmAsked:
Who is Participating?
 
rdivilbissConnect With a Mentor Commented:
With a little JavaScript and CSS you could do this.  In this page if you enter text in the field and select it it will change colors.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>New Page 1</title>
<script type="text/javascript">
<!--
function changeColor(oFld) {
      oFld.style.color= "#FFFFFF";
      oFld.style.backgroundColor = "#000088";
}
//-->
</script>
<style>
<!--

-->
</style>
</head>

<body>

<p><input type="text" name="T1" size="20" onselect="changeColor(this)"></p>

</body>

</html>
0
 
ZylochCommented:
I know of no way to do this with CSS. Highlight colors are controlled by the operating system and maybe the browser. You might try changing the color of the font to see if the highlight color changes, or change the background of the text box, but that is not the same thing.
0
 
cannonarmAuthor Commented:
Sorry rdivilbiss, that code does change colors of the text box and text , but I could not control the highlight colors with that code.  I have to give credit to Zyloch, I do not think it can be done with CSS.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
rdivilbissCommented:
Works in IE, FF, & Opera...

Here is a live example with screen shots.
0
 
ZylochCommented:
@rdivilbiss,

Changing the background color of the field is similar to, but not exactly the same as changing the highlight color, unless I'm mistaken.
0
 
rdivilbissCommented:
What the fore, and back colors are directly affect the highlight (selected) color in almost all browsers.  I'm just setting them temporarily (while selected) to get the desired effect.  It isn't always easy to determine what highlight colors you'll get from a given set of fore and back colors.  It may or may not be feasible for the asker's intent, and it is very limited.  Just not impossible.

I see I forgot the link above: http://www.rodsdot.com/temp_testing/highlight-text-on-select.htm
0
 
ZylochConnect With a Mentor Commented:
I have only really seen two different highlight colors--the navy and the white, but I see your point.
0
 
rdivilbissCommented:
I would never do this on a production web site.

I hate colored scroll bars and inputs.
0
 
rdivilbissCommented:
no opinion
0
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.