Grow your CSS skills. Land your dream job.

What is a .htc File

  • # January 10, 2012 at 4:23 pm

    I’ve seen .htc files here and there, but am unsure what they are used for. How are they used in the site? How do I load it into my site?

    Some web files that I looked at recently included a .htc file, but there was no src to open that file in the .html file provided. However, when I open the .htc file, it says that this particular one is for CSS3 rendering for IE. I gather what this particular .htc file is for because of the title I just mentioned as commented on the inside of it, but am unsure about anything else.

    Please provide some information if you could.

    Thanks

    # January 10, 2012 at 5:26 pm

    .htc files are commonly used in .css files using an IE specific property called behavior, using this along with the .htc file allows the browser to run JavaScript code which is whats contained within the file. See the below example if you were at some point using CSS3 Pie:

    #someSelector {
    behavior: url('/path/to/file/css3pie.htc');
    // Normal properties here...
    }
    # January 10, 2012 at 8:05 pm

    Thank you very much for the information.

    What is CSS3 Pie?

    # January 10, 2012 at 8:07 pm

    OK, so I just read that it means Progressive Internet Explorer, and it is supposed to make IE6-9 support all the most popular and prominently used CSS3 features. But, if behavior is in CSS3, how will IE6-8 even recognize the path to the .htc file? Or, is behavior also in CSS2.1?

    # January 10, 2012 at 8:10 pm

    With a little more research, I discovered that behavior is supported by even IE5.5. So I assume then that the behavior property has been supported since CSS1. And no other browsers support .htc from my initial search. Is this true? So is an .htc file strictly for Internet Explorer browsers, even if my use of a .htc file is something other than CSS3 pie?

    Thanks again for the guidance.

    # January 10, 2012 at 8:11 pm

    Thanks again SgtLegend. Nice name by the way :)

    Taj
    # March 4, 2013 at 12:11 am

    just now i got to know about,what the htc file is,please make me know how to create a path for htc file,and how to get it clearly

    __
    # March 4, 2013 at 1:45 am

    This topic is over a year old. :(

    A path to a `.htc` file is the same as any other.

    relative:

    `path/to/file.htc`

    root-relative:

    `/path/to/file.htc`

    absolute:

    `http://example.com/path/to/file.htc`

    # April 21, 2013 at 9:45 am

    It’s important to note that the relative path has to be relative to the HTML document, not to the CSS file.

    Having this structure:

    /index.html

    /css/styles.css

    /js/file.htc

    the behavior in the css file should use the path: (‘js/file.htc’)

    not (‘../js/file.htc’)

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".