Interview Questions

Why is my external stylesheet not working ?

CSS Interview Questions and Questions


(Continued from previous question...)

59.Why is my external stylesheet not working ?

There may be several different reasons behind that, but one very common mistake is to have an external stylesheet that contains HTML markup in some form.

An external stylesheet must contain only CSS rules, and if required, correctly formed CSS comments; never include any HTML syntax, such as <style type="text/css">…
CSS comments are defined as anything that is placed between
/* (the comment start mark) and
*/ (the comment end mark). I.e. as follows…

/* This text right here is a correct CSS comment */

CSS comments may span multiple lines in the stylesheet. Nesting of CSS comments is not allowed.

Another reason for external stylesheets (and even embedded and inline stylerules) not to function as expected may be that you have tried to make use of some CSS-features that are not supported in the browser you are using.

External stylesheets shall also be served from the www-server with a MIME-type of 'text/css' in its 'Content Type:' HTTP header.
You may need to negotiate with your server admin to add this MIME type to your server if you are not able to configure the server yourself.

(Continued on next question...)

Other Interview Questions