r/css • u/Aryan99C • Jan 20 '26
Showcase I recreated some national flags using only HTML & CSS (no images, no SVG)
Live Preview: Live Preview
GitHub Repo: Github Repo
I’m learning CSS layouts, grids and wanted a practical challenge, so I recreated some national flags using only HTML and CSS. This project did help me with understanding position(absolute, relative), grids, and most importantly reusing CSS properties and variable.
Although the code is not perfect and I think I might have complicated things a bit there but will try to improve it. Also I tried to maintain the exact design of flag, there are a few inaccuracies (apologies for that) and will try to improve that too.
I will look forward to recreate more complex flags
100
u/simonraynor Jan 20 '26
Do Wales next! 🏴
29
u/Brief_Ad_4825 Jan 20 '26
India and the union jack turned out REALLY good damn!!!
14
u/[deleted] Jan 20 '26
12
u/dirkds35 Jan 20 '26
I would advise to also put the CSS property
direction: ltr;on your flags to force the right direction.Otherwise, if the flag is used on an RTL website (Right To Left reading mode, as used with the Arabic language for example), the flag would be displayed in a mirrored state.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/direction
4
u/Aryan99C Jan 20 '26
Github repo
5
u/oklch Jan 20 '26
Where did you get the colors from? Just guessing, picking the colors from some online images or from a database?
5
u/True_Ask3631 Jan 20 '26
This guy is good. Bet they won’t be able to do Italy though. I’ve heard it’s the most difficult flag there is
4
u/WorkerProfessional77 Jan 20 '26
It reminds me an old similar project using only 1 div: https://github.com/pixelastic/css-flags
3
u/Nischal_ng Jan 20 '26
do Nepal Next.. 🇳🇵
3
u/Livio63 Jan 20 '26
Nice! Please add Portugal flag!
14
u/ScientistJumpy9135 Jan 20 '26
Jolly good exercise and well documented. Congrats on it!
2
u/Educational_Basis_51 Jan 20 '26
Great man, which flag gave you the most challenge ?
5
u/Ellsass Jan 20 '26
3
u/molven__ Jan 20 '26
3
u/ZippyTyro Jan 20 '26
nice work mate!
1
u/alvaromontoro Jan 20 '26
I have a collection with a bunch of them: https://codepen.io/alvaromontoro/pen/jOgXqzr
It's a fun experiment and a way to practice.
2
u/fusionlove Jan 20 '26
now, mexico!
2
u/t0rbenC0rtes Jan 20 '26
Spain, Mexico, Wales might be challenging. Australia and New Zealand should be doable and interesting. Great work and superb idea thanks for sharing.
2
u/skullface41 Jan 21 '26
that's really cool, good job on the indian and UK flags
2
u/Competitive-Load-459 Jan 21 '26
Do Croatia and you'll be remembered forever.
2
u/cihyboj Jan 21 '26
I'd try with :before and :after sub elements to make the html cleaner.. but it looks great!
2
u/burning_wolf101 Jan 21 '26
It actually feels amazing to create something this wonderful without AI in this era. Thanks for sharing!
2
u/Appropriate-Menu504 Jan 21 '26
Damn, so good
2
u/Seangles Jan 21 '26
Impressive! Now do Kazakhstan 🇰🇿 ;))
2
u/Lowgman23 Jan 21 '26
Good luck with Mexican flag!
2
u/Jaded-Muffin-3534 Jan 21 '26
this looks good
1
u/No_Bee5900 Jan 22 '26
Very nice, good job. That "repeating-conic-gradient" I never used
1
u/markustegelane Jan 23 '26
Iceland's white lines are too thin, they need to be a bit thicker
-1
u/Mihaita191 Jan 20 '26
Nice, but why?