Make it look acceptable, and learn the two CSS concepts that matter most: the box model and flexbox.
index.html— same as Part 1 plus<link rel="stylesheet" href="style.css">style.css— selectors and declarations
Right-click index.html → Open with Live Server.
selector {
property: value;
}Selectors target elements:
h1— every<h1>.container— every element withclass="container"#task-input— the element withid="task-input"
Every element is a box: content → padding → border → margin. In devtools, click an element and look at the bottom-right diagram — it shows all four layers with their pixel values. box-sizing: border-box (set on * in our stylesheet) makes width/height include padding and border, which is almost always what you want.
How you lay things out. The input and button sit side by side because of:
.row {
display: flex;
gap: 0.5rem;
}That's it. display: flex on a parent turns its children into a horizontal row with the gap between them. Common modifiers:
flex-direction: column— stack vertically insteadjustify-content: space-between— push children to the edgesalign-items: center— vertical alignmentflex: 1on a child — grow to fill remaining space (used here on#task-input)
Almost everything you'll lay out for the next year uses flexbox.
- Change the colour of
#add-btn. Save and watch it update. - In devtools, click the button, go to the Styles panel, and toggle declarations on/off with the checkboxes. Edit values inline. This is the fastest way to learn CSS.
- Change
.rowtoflex-direction: column— input stacks above button. - Add a new property to
#task-list li:padding-left: 1remand see the box model diagram update.
The Add button doesn't add anything. That's JavaScript — Part 3.