Barcodes vs. Serial Numbers

7.18.15


The best way to understand the difference of class and id is through an analogy. While researching this topic I came across an article by Chris Coyier, referencing the difference between barcodes and serial numbers. For example, think of a product you can purchase at a store. On this product is a barcode that the store can scan. This allows the store to know what it is and how much it may cost. This product will have the same barcode on it no matter where you find.

This product will also have a serial number on it, which makes it one of a kind. The serial number doesn't know the price, seeing as that would be insufficient. That way if the price changes you could just change the barcode instead of the serial number. This is similar to classes and ID's, in that reusable date should be stored in a class and all the unique information stored in an ID.

Here is a small example from HTML DOG




blogs