CSS – Specificity & Inheritance & Cascade

CSS – Specificity & Inheritance & Cascade

When the same element is selected by two or more rules, specificity is used to determine which rule wins out. A selector’s specificity is determined by the components of the selector itself. A specificity value is expressed in four parts, like this: 0,0,0,0. The actual specificity of a selector is determined as follows: For every […]

CSS Selectors

Each CSS rule has 2 fundamental parts – the selector and the declaration block. Example: h1 {color: red; background: yellow;} – h1 is the selector, and {…} is the declarations. A value is either a single keyword or a space-separated list of one or more keywords that was permitted for that property. Example: p {font: […]

Enclose CSS in HTML comment tag

it is recommended that you enclose your CSS declarations in a HTML comment tag because with browsers that don’t recognize <style></style>, the tags within them might not get ignored completely and could cause potential problems for the HTML file. <style type="text/css"> <!-- @import url(sheet2.css); h1 {color: maroon;} body {background: yellow;} --> </style> By Bryan Xu

@import directive

@import url(sheet2.css); Just like link, @import can be used to direct the web browser to load an external style sheet and use its styles in the rendering of the HTML document. The only major difference is in the actual syntax and placement of the command. @import is found inside the style container. It must be […]