view raw
Ayaz Ayaz - 8 months ago 42
CSS Question

Assigning external stylesheet to specific table in html

Can I assign an external css stylesheet for a specific table out of many in a single page ?


Yes. You can do it. However using more than one style-sheets is not good from a performance perspective. If you know that you are NEVER going to change your CSS code once you have built it then single style-sheet is best for you. Multiple style-sheet are good if you are going to change your CSS once in while and you need to keep it easily manageable/updateable.

To assign external stylesheet to a specific table:

1.First assign a css class name or css id name (for example I am using class name "table-with-external-SS") to your table in your html page code as below:

<table class="table-with-external-SS">

2.Then create an external stylesheet which target only this table's class.Write css to target only the table with class for e.g. ".table-with-external-SS" as following:

table.table-with-external-SS {
    color: navy;
    background-color: cyan;

3.Save this by any name for example mystylesheet.css. Then link this stylesheet in you html code in head section as below:

<link rel="stylesheet" type="text/css" href="mystylesheet.css">

Hope it helps.