CSS Articles

Page 23 of 130

What is the difference between position:sticky and position:fixed in CSS?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 13K+ Views

In CSS, the position property controls how an element is positioned within the document. Two commonly confused values are fixed and sticky, which behave differently when scrolling. In this tutorial, we will learn the key differences between position: fixed and position: sticky. What is Position: Fixed in CSS? The fixed value positions an element relative to the viewport, removing it from the normal document flow. The element remains in the same position even when the page is scrolled. Syntax selector { position: fixed; top: value; ...

Read More

What is the difference between “screen” and “only screen” in media queries?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 4K+ Views

In CSS, media queries play an important role in creating responsive web designs. We can write media queries using the @media CSS rule with different conditions and keywords to target various devices like mobile devices, desktops, tablets, and printers. In this tutorial, we will learn the difference between 'screen' and 'only screen' in media queries. Syntax /* Using screen */ @media screen and (condition) { /* CSS code */ } /* Using only screen */ @media only screen and (condition) { /* CSS code */ } ...

Read More

What is styling text input caret ?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 680 Views

In HTML text inputs, you can observe a marker showing at the editing position in the text, called the text input caret. It is also known as a text input cursor. This blinking line indicates where the next character will be inserted when typing. In this tutorial, we will learn to style the text input caret using CSS. Currently, we can only change the color of the text input caret, as changing the shape is not supported by modern browsers. Syntax selector { caret-color: value; } Possible Values ...

Read More

Wave inside Text using pure CSS

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 1K+ Views

CSS allows developers to create animated wave effects inside text elements. This technique creates visually appealing text animations that simulate water waves flowing through the letters, enhancing the visual impact of web content. Syntax @keyframes wavey { 0%, 100% { clip-path: polygon(/* initial wave coordinates */); } 50% { clip-path: polygon(/* peak wave coordinates */); } } Method 1: Using Clip-Path Animation This approach uses the clip-path property to create ...

Read More

Which characters are valid in CSS class names/selectors?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 3K+ Views

In CSS, class names and selectors are used to target specific HTML elements for styling. Understanding the rules for valid CSS class names is essential for writing clean, maintainable stylesheets. This tutorial covers all the important rules and valid characters for creating CSS class names. Rules for Valid CSS Class Names Here are the essential rules for creating CSS class names − Rule 1 − Class names should contain only alphanumeric characters (a-z, A-Z, 0-9), hyphens (-), and underscores (_). Rule 2 − Class names cannot start with digits. For example, 123test is invalid. Rule 3 ...

Read More

Transition shorthand with multiple properties in CSS?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 797 Views

We can add transitions to HTML elements using CSS. Before we start with the tutorial, let's understand what transition is. Basically, the transition is an element changing from one state to another state. For example, we change the dimensions of the element when users hover over the element. In CSS, we can add transitions to elements using two ways. First is to use 'transition-property', 'transition-duration', 'transition-timing-function', and 'transition-delay' all 4 properties together. The second is using only the 'transition' CSS property. The CSS 'transition' property is shorthand for the below CSS properties. Transition-property − It specifies ...

Read More

Toggle class by adding the class name when element is clicked and remove when clicked outside

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 6K+ Views

Sometimes, we need to highlight an HTML element when we click it and return it to its normal state when we click outside the element. We can achieve this by toggling CSS classes on the element − adding a class when clicked and removing it when clicked elsewhere. In this tutorial, we will learn to add a class name to an element when users click it and remove the class name when users click outside the element. Syntax element.addEventListener('click', function() { element.classList.add('className'); }); document.addEventListener('click', function(event) { if ...

Read More

Snowfall Animation Effect using CSS

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 853 Views

We can create an animation using HTML and CSS. When we add animation to the webpage, it improves the UX of the application. We can create various animations using the CSS keyframes property and use it using the 'animation' CSS property. In this tutorial, we will learn to create a snowfall animation effect using CSS. Syntax .snow { animation: snow 7s linear infinite; } .snow:nth-child(2) { left: 20%; animation-delay: 1s; } @keyframes snow { 0% { transform: translateY(-100vh); ...

Read More

How to Make Scrollbar Custom Arrows Work on Mobile Devices?

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 2K+ Views

Custom scrollbars can enhance the visual appeal of your website by providing a unique user experience. While modern browsers support custom scrollbar styling through WebKit CSS properties, making these work consistently across mobile devices requires specific techniques. Syntax ::-webkit-scrollbar { width: value; } ::-webkit-scrollbar-thumb { background: color; } ::-webkit-scrollbar-track { background: color; } WebKit Scrollbar Properties PropertyDescription ::-webkit-scrollbarStyles the overall scrollbar element ::-webkit-scrollbar-thumbStyles the draggable part of the scrollbar ::-webkit-scrollbar-trackStyles the background track of the scrollbar ::-webkit-scrollbar-buttonStyles the arrow buttons on ...

Read More

How To Create A Text Inside A Box Using HTML And CSS

Yaswanth Varma
Yaswanth Varma
Updated on 15-Mar-2026 26K+ Views

To create a text inside a box using HTML and CSS, we can use several approaches to add borders around text elements and create visually appealing boxed content. Syntax selector { border: width style color; padding: value; } Approaches to Create a Text Inside a Box Using span element with CSS Using CSS flexbox Method 1: Using Span Element with CSS Border This method uses a element with CSS border and padding properties ...

Read More
Showing 221–230 of 1,299 articles
« Prev 1 21 22 23 24 25 130 Next »
Advertisements