How to Create a Skeleton UI Using HTML and CSS
In today's digital world users want information quick and they wouldn't wait, will move to other site. If your website is taking much time to load users will loose interest and this direcly affects your trust, increase bounce rate. Solution to this problem is using Skeleton Screens.
As we may have seen some of the website has a loader like spinner which indicates that soemthing will appear but its doesn't give any exact information what it will show, but using skeleton structure users can see a preview of the content gives a feeling that some thing will load which makes the users to stay on the website.
In this blog article we will learn how to make skeleton structure by using only html and css without any JavaScript or library.
What is a Skeleton Screen?
Skeleton Screen is basically a blank version of the content it shows when an actual content will load. It can be understood by this example suppose we have written an article which has banner image some paragraphs, author name, images and its takes 1-2 seconds to load then at the time we can use a grey boxes or lines that will indicate those images and texts which gives the user a rough idea that an image or text will appear there.
Why Use Skeleton Screen?
Perceived performance improves Users feel that everything is loading fast.
User engagement remains If the layout is visible, users stay.
Layout does not shift When the actual content comes, there is no jerky movement on the page.
Step by Step: Create a Skeleton UI Card
let's start by making it practically with only using html and css. This approach is helpful where external CSS is not allowedlike emails or basic demos.
We'll create a basic card that looks like a blog post or social feed:
Image placeholder
Title placeholder
Two-line text placeholder
HTML + Inline CSS Example:
<div style="width: 300px; padding: 16px; border: 1px solid #ddd; border-radius: 8px;">
<!-- Image Placeholder -->
<div style="width: 100%; height: 180px; background: #eee; border-radius: 8px;"></div>
<!-- Title Placeholder -->
<div style="width: 70%; height: 20px; background: #e0e0e0; margin: 16px 0 10px; border-radius: 4px;"></div>
<!-- Text Line 1 -->
<div style="width: 90%; height: 14px; background: #e0e0e0; margin-bottom: 8px; border-radius: 4px;"></div>
<!-- Text Line 2 -->
<div style="width: 60%; height: 14px; background: #e0e0e0; border-radius: 4px;"></div>
</div>
Output Preview:
This code creates a card with:
An image placeholder at the top
A title placeholder in the middle
Two lines below that will show the content
The background color is soft grey (#eee, #e0e0e0) which gives a smooth skeleton feel.
Adding Animation for Realism
If you want more realistic feel then you can add an animation or shimmer effect which gives an indication that content is loading.
Simple shimmer using inline CSS:
<div style="
width: 300px;
height: 20px;
background: linear-gradient(90deg, #eee 25%, #ddd 50%, #eee 75%);
background-size: 200% 100%;
animation: shimmer 1.5s infinite;
border-radius: 4px;
"></div>
@keyframes shimmer {
0% { background-position: -200% 0; }
100% { background-position: 200% 0; }
}
Note: For Shimmer effect @keyframes is required which cannot be done inline, we have to use style tag for basic effect the above styles are enough.
Creating a Full Page Skeleton Layout
If you need to create multiple cards or an entire feed, you can use Flexbox and Repeat Cards.
<div style="display: flex; flex-wrap: wrap; gap: 16px;">
<!-- Repeat the single skeleton card multiple times -->
<div style="width: 300px; padding: 16px; border: 1px solid #ddd; border-radius: 8px;">
<div style="width: 100%; height: 180px; background: #eee; border-radius: 8px;"></div>
<div style="width: 70%; height: 20px; background: #e0e0e0; margin: 16px 0 10px; border-radius: 4px;"></div>
<div style="width: 90%; height: 14px; background: #e0e0e0; margin-bottom: 8px; border-radius: 4px;"></div>
<div style="width: 60%; height: 14px; background: #e0e0e0; border-radius: 4px;"></div>
</div>
</div>
Where Skeleton Screens Are Used
This feature is used in many industries:
| Industry | Use Case |
|---|---|
| E-commerce | When loading the product list |
| News | Before loading headlines or articles |
| Social Media | Feed content loading |
| Dashboard | Before you see charts or stats |
Best Practices for Skeleton Screens
If you want to make an effective skeleton, then follow these tips:
Key Properties of CSS Grid:
Match Real Layout: The layout of the skeleton should match the original content.
Don’t Delay Content: Show the content as it is available do not hold the skeleton unnecessarily.
Use Subtle Colors: Do not use bright or dark colors soft grey shades are best.
Avoid Overusing: It is not necessary to show the skeleton for every small delay it is better not to show the spinner or anything for a delay less than 500ms.
Frequently Asked Questions (FAQs)
What’s the difference between a spinner and a skeleton screen?
Answer: Spinner is a normal animation that just shows the load, but the skeleton represents the layout of the screen content. This gives the user an idea of what is going to come.
Can I create skeleton screens without JavaScript?
Answer: Yes, absolutely! As mentioned above, you can create a skeleton without HTML + CSS especially for basic layout placeholders.
Are skeleton screens good for SEO?
Answer: It does not directly affect the SEO, but indirectly the bounce rate reduces, time on the site increases - which improves the SEO.
Do skeleton screens work on all browsers?
Answer: Yes, basic skeleton using div and background color works in all modern browsers. Browser support should be checked for animation.
Conclusion
Skeleton screen is a smart as well as modern trick that makes the loading time for any website or app feel a bit more natural and user-friendly. This one is more effective than spinners, as it gives an idea of the actual content's approximate look. There isn't any confusion, as a result.
The best part? You can create a simple and clean skeleton screen using just HTML and inline CSS. No heavy library or complex code needed perfect if you're making a quick demo, working with a CMS, or want a lightweight layout.
So next time when you want to show loading state in a project, try skeleton screen instead of spinner. Users will also find it more intuitive and your UI will look more professional. A little effort, but big impact.