Solved

Textbox highlight color html

Posted on 2007-03-31
10
1,317 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:cannonarm
  • 5
  • 3
10 Comments
 
LVL 36

Expert Comment

by:Zyloch
Comment Utility
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
 
LVL 29

Accepted Solution

by:
rdivilbiss earned 150 total points
Comment Utility
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
 

Author Comment

by:cannonarm
Comment Utility
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
 
LVL 29

Expert Comment

by:rdivilbiss
Comment Utility
Works in IE, FF, & Opera...

Here is a live example with screen shots.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 36

Expert Comment

by:Zyloch
Comment Utility
@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
 
LVL 29

Expert Comment

by:rdivilbiss
Comment Utility
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
 
LVL 36

Assisted Solution

by:Zyloch
Zyloch earned 100 total points
Comment Utility
I have only really seen two different highlight colors--the navy and the white, but I see your point.
0
 
LVL 29

Expert Comment

by:rdivilbiss
Comment Utility
I would never do this on a production web site.

I hate colored scroll bars and inputs.
0
 
LVL 29

Expert Comment

by:rdivilbiss
Comment Utility
no opinion
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article discusses how to create an extensible mechanism for linked drop downs.
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 …
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 the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

762 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

7 Experts available now in Live!

Get 1:1 Help Now