Generic Cascading Order
Consider a scenario where you have multiple style sheets defied for an HTML page.
These style sheets might have various selectors and multiple styles defied for an HTML
element. Therefore, W3C has defied some rules for applying styles to an HTML element.
These rules are as follows:
- Gather all the styles that are to be applied to an element.
- Sort the declarations by the source and type of style sheet. The source specifies the origin from where the styles are rendered.
is of the reader, which can be a software that reads the content (screen reader software),
and the last priority is of the browser.
The highest priority is given to the external style sheet defied by an author. The next priority
is of the reader, which can be a software that reads the content (screen reader software),
and the last priority is of the browser.
is of the reader, which can be a software that reads the content (screen reader software),
and the last priority is of the browser.
- Sort the declarations by the priority of a selector, where the ID selector has the highest priority.
- Sort the declaration according to the specified order.
CommentsA comment refers to the descriptive text that allows a Web page designer to provide
information about the CSS code. Comments make the program more readable and helpthe designer to explain the styles specified for elements. This is helpful when other Web
designers analyze the CSS code.
The browser can identity comments as they are marked with special characters, which are
‘/*’ and ‘*/’. When the browser encounters these symbols, the text within them are ignored
and are not displayed in the browser. You can have single-line and multi-line comments in
the CSS fie.
No comments: