Change selection color

2 posts Page 1 of 1
Contributors
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Change selection color
Codex
Hey,

//Originally posted on my site but I decided to share with CodenStuff members too.
//Original topic can be found here: http://codexvideos.com/viewtopic.php?f=23&t=163

Ever wondered how some sites change the selection color when you highlight some word or sentence ?
In this tutorial we are going to show you how to change the selection color to which ever color you want.

Step 1
Open your CSS file
If you are not using a CSS file then just add the code in Step 2 between
Code: Select all
<style type="text/css">          </style>
Step 2
Insert this code
Code: Select all
::selection {
color: white;
background-color: #D33;
text-shadow: none;
}
Now let's split the code in 3 parts,
  • Code: Select all
    color: white;
    This code will set the text's color when it's highlighted/selected to white, you can change this to whatever color you want.
    Code: Select all
    background-color: #D33;
    This code will set the selection color when text is highlighted/selected to #D33 (red), you can also change this to your preferred color.
    Code: Select all
    text-shadow: none;
    Now this code is not needed if you don't have any shadows on the text, but if you do, this will make the selection 'prettier'.
Now that's it, happy experimenting.
CodexVideos
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Re: Change selection color
Shim
good tutorial
Find my programs on Softpedia
2 posts Page 1 of 1
Return to “Tutorials”