Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Change DefaultText Selection Color with CSS | CSS Change Text Highlight Color

Apr 1, 2013
Introduction

Here I will show how to change default text selection color with CSS in website or change text highlight color using CSS in website.

Description:
  
In previous articles I explained
jQuery Change background color of div, jQuery fadein fadeout effect, jQuery get current page url and title, jQuery create rounded corners for textbox and many articles relating to JavaScript, jQuery, CSS, asp.net. Now I will explain how to change text selection color using CSS in website.

To change text selection color using CSS we need to write the CSS classes like as shown below

<style type="text/css">
/* For Mozilla Browser */
::-moz-selection {
background: #d91900;
color: #fff;
}
/*For Other Browser*/
::selection {
background: #d91900;
color: #fff;
}
</style>
If you want to see it in complete example check below code


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Change Text Selection Color using CSS</title>
<style type="text/css">
/* For Mozilla Browser */
::-moz-selection {
background: #d91900;
color: #fff;
}
/*For Other Browser*/
::selection {
background: #d91900;
color: #fff;
}
</style>
</head>
<body>
<div>
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET <br />
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET <br />
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET <br />
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET <br />
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET <br />
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET <br />
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET <br />
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET <br />
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET <br />
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET <br />
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET <br />
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET <br />
</div>
</body>
</html>
Live Demo

For live demo try to select below text


Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET
Welcome to aspdotnet-Suresh.com. This site will provide articles relating to .NET

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

2 comments :

Anonymous said...

not working in my example...

Anonymous said...

Working..

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.