当用户第一次访问我的网站时,制作文本的CSS样式

I have a web site. Here in my home page there is a content "My dummy text ". which is placed in ul li a tag. ie

<ul><li><a>My dummy text</a></li></ul>

i want to make this text should highlighted in blue when someone first lands on the home page. other wise it's must be in white. Does any one know how to do this ? mine is a php web site

Thanks in advance

Just to add a little onto the cookie method I suggest adding a class to the <body> tag so that if in the future you want to do more you could do it without having to modify the PHP.

For example:

<?php 
      function dejavu() {
          $class = '';
          if($_COOKIE['beenHereBefore']) {
             $class .= 'beenHereBefore';
           }
          else {
             $class .= 'firstTimeHere';
             setcookie("beenHereBefore", true);
          }
          return $class;
      }
?>

<body class="<?php echo dejavu(); ?>">

One thing that you want to take into account though is that if a user clears their cookies then it will act as though they are visiting the site for the first time; so I suggest, if possible store it in their user profile if one exists.

So then in your CSS you can do the following:

ul li a {color: white;}
.firstTimeHere ul li a {color: blue;}

you can use cookie

  1. set default 0
  2. if someone loaded the page than change cookie to 1 otherwise 0

.

<ul>
   <li>
    <a <?php if($_COOKIE["status"] == 0){style="color:blue;"} ?>>My dummy text</a>
   </li>
 </ul>

I dont see any code so..here is my theoritical explaination as well...

1 Use Cookies.
2 HTML5 Cache..You can use localstorage to do that as well

Use:

$(window).ready(function(){
// do your CSS stuff here ...
});

Or use :

$(document).ready(function(){ 
// do your CSS stuff here ...
});

Check this link : http://api.jquery.com/ready/

I advise you to do it using jquery to check if you are in the home page Assume your home page is called : index.php

Like this :

if(window.location.href.indexOf("index.php") > -1)
{
      $('#ulid li').css('color', 'red');
}
else $('#ulid li').css('color', 'black');

Give your ul an ID and assume you want to highlight using red and your original text color was black No need to use Cookies you can do this trick using jquery very easily .