Important topics in CSS
Hello everyone! Welcome to my blog. Today we are going to explore some most important topics in CSS.
1. Box model:
In CSS all the HTML elements are considered as box model. The Box Model in CSS is a fundamental concept that explains how HTML elements are rendered on a web page. Every element in a webpage is treated as a rectangular box, and the box model defines the structure of that box.
2. CSS selectors:
CSS selectors are patterns used to select and style the HTML elements you want to apply styles to. They are the most basic part of CSSβyou use them to target specific elements on a page.
- Class selector
- ID selector
- Element selector
- Combination selector, etc.
3. CSS position:
The position property in CSS is used to control how an HTML element is placed on a webpage.By default, elements appear one after the other in the normal document flow. But when you use position, you can move elements anywhere on the screen β relative to the page, their parent, or even the screen itself.
Types of Position:
- Static
- Relative
- Absolute
- Fixed
- Sticky
4. Flex and Grid:
Flexbox: Flexbox(Flexible Box) is a one-dimensional layout system β it helps you align items in a row or a column, especially when the size of items is dynamic or unknown.
When to use?
- When you're laying out items in a single direction (row or column).
- Ideal for navbars, menus, buttons, and simple alignment tasks.
Grid: CSS Grid is a two-dimensional layout system β it lets you layout items in rows and columns at the same time.
When to use?
- When your layout is complex (like a website layout with header, sidebar, main, footer).
- You want to control both rows and columns precisely.
5. Media query and Animation:
Media query: Media queries are a way to apply CSS only when a certain condition is true β like screen size, resolution, or orientation.
Theyβre essential for responsive design β so your site works well on all devices.
Parts:
- @media β This tells the browser βStart a media query.β
- Media Type β Like screen, print, all. Most common is screen.
- Media Feature β Conditions like width, height, orientation, etc.
- Logical Operators β Use and, or, not to combine conditions.
Animation: Animations let you change CSS properties over time β making your webpage look more dynamic or interactive.
Required:
- animation-name β Refers to the @keyframes block.
- animation-duration β How long the animation takes (e.g. 2s, 1.5s).
- animation-timing-function β The speed curve (ease, linear, etc.).
- animation-delay β How long to wait before starting.
- animation-iteration-count β How many times to repeat (1, infinite).
- animation-direction β normal, reverse, alternate.
That's it. When I am prepare for my interviews I found that these are the important topics in CSS. Moreover In my past two interviews they ask question in these topics as well. So I thought It would be great to share these with you.Thank you for reading this. I hope you like this. Will see you in my next blog