Tag Archives: css internal

Specificity & Cascade Rule Css External, Internal, Inline Style Sheets

External Style Sheet:
Enter Following Code between HEAD tags of web page.
eg. Available Continued Link
This will links to your .css file once you define your path.
NOTE:
(Site Editor does not allow CSS Code but can view Article Continued Link)

eg. @import method – use within the STYLE tags:
Available Continued Link

eg. import file within a CSS style sheet: @import
Available Continued Link
(NOTE: @import rule must come before all other content in .css (comments included) or .css may not load properly)
(Efficient; global changes for large web sites can occur automatically by altering only one file. Ensures a consistent look, easier maintenance, improved flexibility for updating, saves download times (style sheet is cached, net weight of page decreases).

Internal Styles are EMBEDDED within HEAD tags using STYLE tags
eg. Available Continued Link
(NOTE: Styles within this method SUPERSEDE styles in External Sheets).
(Increases load time but useful if testing pages; saves time)
(NOTE: The More Specific Rule between internal and external style sheets WINS the SPECIFICITY contest).

Inline Style Attribute:
Code is entered within tags using the XHTML style attribute (this case paragraph tags).
eg. p tags Available Continued Link
(Inline styles have the highest priority, HOWEVER keep in mind this could interfere with the Cascade Rule. Benefit; quick to alter one-off or less occurring situations). This method mixes content with presentation losing many of the advantages of style sheets.

The Cascade Rule influences the flow down effect of the CSS selectors with a Weight or Order of importance assisting browsers to interpret hierarchy of selectors to parse. Basically it Resolves conflict between selectors.
Specificity (determines how specific a CSS rule is) it’s determined by ID attribute count, how many pseudo-classes are in the selector, and number of element names in the selector.

The rule coded last takes precedence if two+ style rules are considered equal in specificity.

Specificity is calculated by ranking selectors; Inline Selector TOP > NEXT ID’s Selector > THEN classes/pseudo class Selectors > LAST Tag Elements/pseudo elements (CSS 2.1). Calculation represented in this fashion 0-0-1-1 (the higher number wins specificity race).

Remember Inline Styles take Precedence over ALL.

COMPLETE ARTICLE Includes Specificity Calculation Continued Authors Link

Tagged , ,