Created
May 15, 2024 09:35
-
-
Save primitiveshaun/8718f6ec65f988f9d8951bb9a33a9e2c to your computer and use it in GitHub Desktop.
Modern and Minimal CSS Reset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Modern and Minimal CSS Reset */ | |
/* Remove default margins and paddings */ | |
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
/* Set base font properties */ | |
html { | |
font-family: sans-serif; | |
line-height: 1.15; | |
-webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape */ | |
scroll-behavior: smooth; /* Enable smooth scrolling */ | |
} | |
/* Set base styles for common elements */ | |
body { | |
margin: 0; | |
} | |
/* Remove list styles */ | |
ul, | |
ol { | |
list-style: none; | |
} | |
/* Remove default quotes from blockquotes and q */ | |
blockquote, | |
q { | |
quotes: none; | |
} | |
blockquote::before, | |
blockquote::after, | |
q::before, | |
q::after { | |
content: ''; | |
content: none; | |
} | |
/* Set border box sizing for all elements */ | |
*, *::before, *::after { | |
box-sizing: inherit; | |
} | |
/* Remove text decoration from links */ | |
a { | |
text-decoration: none; | |
color: inherit; /* Inherit color from parent */ | |
} | |
/* Remove default button styles */ | |
button, | |
input, | |
select, | |
textarea { | |
font-family: inherit; /* Inherit font from parent */ | |
font-size: inherit; /* Inherit font size from parent */ | |
line-height: inherit; /* Inherit line height from parent */ | |
color: inherit; /* Inherit color from parent */ | |
background: none; | |
border: none; | |
padding: 0; | |
margin: 0; | |
} | |
/* Ensure media elements display as block */ | |
img, | |
svg, | |
video, | |
canvas, | |
audio, | |
iframe, | |
embed, | |
object { | |
display: block; | |
max-width: 100%; /* Ensure media elements do not exceed their container's width */ | |
} | |
/* Remove default table styles */ | |
table { | |
border-collapse: collapse; | |
border-spacing: 0; | |
} | |
/* Ensure form elements inherit font styles */ | |
button, | |
input, | |
optgroup, | |
select, | |
textarea { | |
margin: 0; /* Remove default margins */ | |
} | |
/* Set base box sizing */ | |
html { | |
box-sizing: border-box; | |
} | |
/* Remove default fieldset border */ | |
fieldset { | |
border: none; | |
} | |
/* Make sure hidden elements stay hidden */ | |
[hidden] { | |
display: none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Explanation
*
): Resets margin and padding for all elements and setsbox-sizing
toborder-box
for predictable element sizing.border-box
.a
): Removes text decoration and ensures links inherit colour.img
andvideo
are displayed as block and do not exceed their container’s width.hidden
attribute are not displayed.This reset provides a solid foundation for a modern web project, ensuring consistency and a clean slate for further styling.