How to Create Fade-in Effect on Page Load using CSS? Last Updated : 18 Jun, 2025 Comments Improve Suggest changes Like Article Like Report To create a fade-in effect on page load using CSS, apply the opacity property in conjunction with the transition property to smoothly change the element's opacity from 0 to 1.opacity Property: Sets the transparency level of an element, with 0 being fully transparent and 1 fully opaque.transition Property: Enables smooth changes between property values over a specified duration. index.html <html > <head> <style> body { opacity: 0; animation: fadeIn 2s forwards; } @keyframes fadeIn { to { opacity: 1; } } </style> </head> <body> <h1>Welcome to My Website</h1> <p>This content will fade in on page load.</p> </body> </html> Code OverviewInitial Opacity: The body element starts with opacity: 0;, making it fully transparent.Animation Definition: The fadeIn animation is defined using @keyframes, transitioning the opacity to 1.Applying the Animation: The animation property on the body sets the duration to 2 seconds and uses forwards to retain the final state.Using CSS animation propertyTo create a fade-in effect using the CSS animation property, define keyframes with opacity settings (0 and 1) and apply the animation to the target element.Use @keyframes to define the animation steps for opacity.Apply animation with properties like duration, ease, and fill mode to control the effect. index.html <html> <head> <style> body { animation: fadeInAnimation ease 3s; animation-iteration-count: 1; animation-fill-mode: forwards; } @keyframes fadeInAnimation { 0% { opacity: 0; } 100% { opacity: 1; } } </style> </head> <body> <b> How to create fade-in effect on page load using CSS </b> <p> This page will fade in after loading </p> </body> </html> Using transition PropertyTo implement a fade-in effect on page load using the CSS transition property, set the initial opacity of the body to 0 and adjust it to 1 upon loading. index.html <html> <head> <style> body { opacity: 0; transition: opacity 3s; } </style> </head> <body onload="document.body.style.opacity='1'"> <b>How to create fade-in effect on page load using CSS</b> <p>This page will fade in after loading</p> </body> </html> Code OverviewInitial Opacity and Transition: The body starts with opacity: 0 and a transition is set for the opacity property over 3 seconds.Onload Event: When the page loads, the onload event sets the body's opacity to 1, triggering the transition and creating a fade-in effect. Comment More infoAdvertise with us Next Article How to Create Fade-in Effect on Page Load using CSS? sayantanm19 Follow Improve Article Tags : Web Technologies CSS CSS-Misc Similar Reads How to Create Skeleton Screen Loading Effect using CSS? The skeleton screens are used to indicate that the content is loading. They are also called splash screens. This is a part of the modern design trend. The skeleton screens are better than the loading spinners in some cases. It is used by many big companies like Facebook, Google, etc. HTML Code:In th 4 min read How to Create an Image Overlay Fade in Text Effect on Hover using CSS ? In the context of web design, it's all about making dynamic and interesting user experiences(UI). Adding picture overlay effects to the website is a good method to improve the aesthetic appeal, especially when users interact with it by hovering over images. This article will walk you through the ste 3 min read How to create a marquee effect using CSS ? In this article, we will be creating the marquee effect by using HTML and CSS. This effect can be created by using the <marquee> tag in HTML, but we will not use this tag as it is not widely used nowadays. We will create and design a marquee effect by using the CSS classes and styling properti 2 min read How to create windows loading effect using HTML and CSS ? In this article, we are going to create a window loading effect before the lock screen appears using HTML and CSS. Glimpse of the Windows Loading Effect: Approach: Create an HTML file that contains HTML div in which we are giving the loader effect.Then we create 5 span elements which are used for c 4 min read How to create image overlay hover slide effects using CSS ? In this article, we will learn how to make image overlay hover slide effects using CSS. When the users hover over the image, a smooth sliding overlay effect occurs. This technique gives a visual appeal with interactivity, making your website more interactive.Table of ContentFull Width Slide-In Text 4 min read How to create paper corner fold effect on hover by using HTML and CSS? The folding effect is quite attractive on the website, may you have seen on some websites when you hover on the paging layout it gets folded on the corner. The folding corner effect can be achieved by using HTML and CSS only. The below sections will guide you on how to create the animation. In this 3 min read How to Create Page Loading Animation Effect using jQuery? In this article, we are going to learn how to create page loading animation effect (Please Wait, Loading... animation) using jQuery, A "Please Wait, Loading..." animation is a visual indication shown during data retrieval or processing, assuring users that content is being fetched or actions are in 6 min read How to create an Image Overlay Zoom Effect on hover using CSS ? Image Overlay Zoom Effect on hover can be done by using CSS. This effect is used in web design for user attention to images by highlighting the content or text, and to improve the overall look of a website by adding dynamic visual effects. We have given a Zoom effect to the text and image when the u 2 min read How to Create Circle Loading Animation Effect using CSS ? In this article, we will see how to create a circle-loading animation using HTML and CSS, along with understanding its basic implementation through the example. Generally, Loading Animation is utilized to wait for the content to be fully loaded on the webpage. If some pages don't contain the loader, 6 min read How to add fade-in effect using pure JavaScript ? The fade effect is described as the gradual increase and decrease in the opacity of the selected portion. In other words, the fade effect is termed as the increase and decrease in opacity with respect to time. When this effect is applied with a gradual increase in the opacity it is known as the fade 4 min read Like