iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

CSS Default Values

Every CSS property has an initial value the spec assigns when nothing else is set. Knowing the most common ones saves debugging time.

Layout

PropertyInitial value
displayDepends on element — block for div, inline for span.
positionstatic
box-sizingcontent-box (almost everyone overrides to border-box).
width / heightauto
margin / padding0 (but elements have user-agent defaults).
overflowvisible
z-indexauto

Visual

PropertyInitial value
colorcanvastext (system black).
backgroundtransparent / none
bordermedium none currentColor — no border because style is none.
border-radius0
opacity1
visibilityvisible

Type

PropertyInitial value
font-sizemedium — typically 16px.
line-heightnormal — ~1.2 of font-size.
font-familyUser-agent default.
text-alignstart
white-spacenormal
Tip: "Reset" stylesheets (Eric Meyer's, Normalize, modern-normalize) exist specifically because user-agent defaults differ between browsers. Apply one early.

Example

Example
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: Verdana, sans-serif; }
.box { background: #04AA6D; color: #fff; padding: 20px; border-radius: 6px; }
</style>
</head>
<body>

<h1>CSS Default Values</h1>
<div class="box">Edit the CSS on the left, then click Run &raquo;</div>

</body>
</html>
Try it Yourself »

Exercise

The default value of `position` is…

Answer:

Test yourself

Q1. Default `position` is…
Q2. Default `box-sizing` is…
Q3. Default `overflow` is…

Discussion

Loading…