Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

Preflight

Why does the heading look like ordinary text, and why did the list lose its bullets? Every browser has its own built-in styles: headings are big and bold, paragraphs and lists have margins, lists have bullets, and links are blue and underlined. Each browser does it a little differently, and when you style a page, you keep running into them: here a margin you never asked for, there a size you didn't choose.

That's why, before any of your classes, Tailwind applies its own base styles, called Preflight, which remove the browser's built-in styles. Here's a part of them:

*,
::before,
::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	border: 0 solid;
}

h1, h2, h3, h4, h5, h6 {
	font-size: inherit;
	font-weight: inherit;
}

ol, ul {
	list-style: none;
}

a {
	color: inherit;
	text-decoration: inherit;
}

The first rule may look familiar: stylesheets in the CSS course often started with a similar one. The value inherit means that the element takes the value from its parent, so a heading has the same size and weight as the text around it. And list-style: none removes the bullets.

Thanks to Preflight, an element looks only the way your classes say, in every browser. Headings and lists still mean the same as before (for search engines and screen readers, a heading is still a heading); they just don't look like it until you style them. That's also why everything on our page is squeezed together: nothing has margins. You'll add space in the lesson on spacing and sizing.

So let's give the heading a size. The class text-3xl sets the font size to 1.875rem (30 px), together with a matching line height:

.text-3xl {
	font-size: 1.875rem; /* 30 px */
	line-height: 2.25rem; /* 36 px */
}

(Tailwind's real CSS uses variables instead of these numbers, but the result is the same.) The 3xl in the name is a size, like on clothes: Tailwind has a whole scale of them, from text-xs to text-9xl, and you'll get to know it in the next lesson.

The bullets need two classes:

  • list-disc is list-style-type: disc: the items get bullets in the shape of a filled circle, a disc.
  • list-inside is list-style-position: inside: the bullet is inside the item, in front of its text. Without it, the bullet hangs outside the item, to the left of it, in the space that the list's padding makes for it. Preflight took that padding away, so a bullet outside the item would end up beyond the left edge of the page, where you can't see it.

Instructions

  1. 1

    Add the class text-3xl to the h1 heading.

  2. 2

    Add the classes list-disc and list-inside to the list (the ul element).

Back

5/9

  1. 1. What Is Tailwind?
  2. 2. Turning Tailwind On
  3. 3. Quiz: Linking the Stylesheet
  4. 4. Several Classes at Once
  5. 5. Preflight
  6. 6. Reading Class Names
  7. 7. When a Class Does Nothing
  8. 8. Quiz: A Class That Does Nothing
  9. 9. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.