selected option css color code example

Example 1: css selected color

::selection {
    background-color: #222;
    color: white;
}

Example 2: change background color with user option

<form action="" method="post">

<select name="Color">
	<option value="White">White</option>
	<option value="Red">Red</option>
	<option value="Green">Green</option>
	<option value="Blue">Blue</option>
	<option value="Pink">Pink</option>
	<option value="Yellow">Yellow</option>
</select>

<input type="submit" name="submit" value="Get Selected Values" />

</form>
<?php

if(isset($_POST['submit'])){

	$selected_val = $_POST['Color'];  // Storing Selected Value In Variable
	echo "<style>body{background-color:".$selected_val.";}</style>";  // Displaying Selected Value

}

?>