HTML Text Highlighter
6/13/2005 11:30:20 PM GMT
I get asked a lot how I create certain things on my web site or on professional sites. Obviously, a lot of it comes from years of study and practice, but for simple and easy to explain things I definately like to share those things.
So I was asked recently how to highlight HTML text and to tell you the truth it is pretty easy, at least for browsers other than IE You may follow this blog or view a very plain example I posted recently in another of my directories.
Site Administrator
The Code
6/13/2005 2:43:26 AM GMT
Highlighting text with everything except Internet Explorer (IE) is a breeze, all you need to do is:
a:hover{color: red;}.
But for (IE, things get a little tougher. See (IE tries to make their Web Development tools (i.e. Visual Studio, FrontPage) work with previous versions of (IE as well as deprecated HTML.
So instead of using an a tag, we have to use a .htc file, which means HTML Component. Component, well not really, just some JavaScript to do the dynamic text instead of CSS. So some typical code looks like this.
<component>
<attach for=element event=onmouseover handler=hig_lite />
<attach for=element event=onmouseout handler=low_lite />
<script type=text/javascript>
function hig_lite()
{
element.style.color = #369
}
function low_lite()
{
element.style.color = silver
}
</script>
</component>
Then to call the JavaScript code, you do a: p{behavior: url(../stylesheets/hover.htc);}. Interested in a live demo other than this page, check this out and go ahead and view the code, that's why it's there.