Vinod Sebastian – B.Tech, M.Com, PGCBM, PGCPM, PGDBIO

Hi I'm a Web Architect by Profession and an Artist by nature. I love empowering People, aligning to Processes and delivering Projects.

Advertisements




CSS Tips and Tricks

Understanding CSS Display Property

The display: none property in CSS is used to hide an element completely from the layout. This means the element will not be visible and will not take up any space on the page. On the other hand, the visibility: hidden property hides the element without affecting the layout. The element is not visible, but space is reserved for it in the layout.

Block Elements in CSS

In CSS, block elements are those that start on a new line and take up the full width available. They create a line break before and after themselves, affecting the layout of the page. Examples of block elements include <div>, <p>, and <h1> to <h6>.

Pseudo Classes and Elements in CSS

  • Pseudo-classes in CSS are used to define special states of an element. They are written with the syntax selector:pseudo-class { property: value; }. Examples of pseudo-classes include :link, :visited, :active, and :hover.
  • Pseudo-elements in CSS allow styling specific parts of an element. They are written with the syntax selector:pseudo-element { property: value; }. Examples of pseudo-elements include ::first-letter, ::first-line, ::before, and ::after.

Understanding Selector Precedence in CSS

In CSS, when multiple selectors target the same element, the selector with the highest specificity will take precedence in styling that element. Specificity in CSS is calculated based on the type of selector used. For example, ID selectors have a specificity of 100, class selectors have a specificity of 10, and HTML selectors have a specificity of 1.

Introduction to @ At-Rules in CSS

@-rules in CSS are special instructions or directives for the CSS parser. Some common @-rules include:

  • @charset: This rule defines the character encoding of an external style sheet and must be the first rule in the file.
  • @import: The @import rule allows importing one style sheet into another. It is important to note that all @import rules must come before any other rules in the file.