anks, you are directly echoing two lines of HTML instead of concatenating them with the $navigation variable.
Also, based on the number of blank lines, you are apparently echoing other things or have something not enclosed within <?php ?> tags before the doctype tag.
Hello,
Ok, i have removed both echo statments and concatenated with the $navigation. like:
$navigation.= "<li class='departments'><a href='".($keywordname_url).".htm'>".Ucwords($keywordname)."</a></li>";
Its showing no error but the Department class is not getting applied. 
But if i echo, as i did earlier, this class gets applied.
Ok, it seems i was not declairing the class in CSS properely, i was prefixing the Class with "#" and not "."
So its woking now.
I appreciate words from all and thanks again!!!