Element Width
Part of the Fundamentals section of Coddy's Tailwind CSS journey. Lesson 31 of 55.
A w-40 tile is 160 pixels wide with the default spacing unit. Width utilities such as w-full instead use the containing block width, while fractional utilities such as w-1/2 use half of it.
<div class="p-4 w-40">Museum sample</div>Use fixed widths for deliberately measured elements and relative widths for elements that must adapt to their container. With border-box sizing, padding and borders stay within an explicit width.
Challenge
MediumSet the ticket preview to a width of 288 pixels, including its supplied padding.
Keep the supplied content and element IDs. Edit the HTML utility classes or the requested CSS. Click Run preview to refresh the preview after edits, then use Check/Run code to grade your work.
Try it yourself
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Practice studio</title><link rel="stylesheet" href="./styles.css"></head><body>
<div id="target" class="p-4">Ticket preview</div>
</body></html>
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
1Meet Tailwind
A Styled First RunChoosing UtilitiesCombining UtilitiesThe Local StylesheetRecap: Meet Tailwind7Sizing and Overflow
Element WidthElement HeightMaximum WidthOverflow BehaviorRecap: Sizing and Overflow