-
CSS Syntax
-
CSS Selectors
-
CSS How To
-
CSS Comments
-
CSS Colors
-
CSS Backgrounds
-
CSS Borders
-
CSS Margins
-
CSS Padding
-
CSS Dimension
-
CSS Box Model
-
CSS Outline
-
CSS Text
-
CSS Fonts
-
CSS Links
-
CSS Lists
-
CSS Tables
-
CSS Display
-
CSS Position
-
CSS Overflow
-
CSS Float
-
CSS Align
-
CSS Combinators
-
CSS Pseudo-class
-
CSS Opacity
-
CSS Attr Selectors
-
CSS Forms
-
CSS Transitions
-
CSS Transforms
-
CSS Animations
-
CSS !important
-
CSS Flex
-
CSS GRID
-
CSS Media Queries
CSS Comments
In coding, comments are invaluable. They allow developers to leave notes, explanations, or reminders within the code without affecting the actual functionality. In CSS, comments play a similar role, providing clarity and aiding in collaboration among developers.
Syntax
In CSS, comments are wrapped between `/*` and `*/`.
/* This is a single-line comment */
/*
This is a multi-line
comment in CSS
*/
Why Use Comments?
Clarification: If a particular CSS rule or method might seem unclear or unconventional, a comment can explain the reasoning or methodology behind it.
Collaboration: When working in a team, comments can communicate intentions, highlight issues, or leave instructions for other developers.
Debugging: Temporarily commenting out certain blocks of CSS can assist in pinpointing issues or bugs.
To-Do Reminders: Developers can leave reminders for themselves or others to revisit certain sections of the code.
Segmentation: Comments can also be used to segment or categorize styles, making the stylesheet more organized. For instance:
/* ============
Typography
============ */
body {
font-family: Arial, sans-serif;
}
/* ============
Layout
============ */
.container {
width: 80%;
margin: 0 auto;
}
Points to Remember
Overcommenting: While comments are helpful, excessive commenting can clutter a stylesheet. Use them judiciously.
Visibility: Comments in CSS are visible in the source code. Avoid leaving sensitive or inappropriate information in comments, as anyone who views the source can read them.
Performance: While comments slightly increase the file size of your stylesheets, the impact on performance is negligible, especially when CSS files are minified for production.
Course Video
YouTube Reference :
1) CSS Comment In Hindi/Urdu