At the end of the lab we will ask you to fill out this form so we can review your progress today. Labs could be considered class participation.
https://forms.gle/iyjhniGp4tJZMy949

In this lab, we will learn:
HTML provides the structure of a webpage, but without CSS, everything would look very plain.
CSS is used to style web pages by controlling how elements look.
Can be used to change:
Made up of rules, containing two parts:
In this example, h1 is the selector, which means this rule will apply to all h1 elements on the page.
Inside the curly braces {} is the declaration: color: deeppink;. This means that all h1 elements will now appear in deep pink.
.css file and linked to the HTML file.Here, the link tag connects the HTML file to styles.css, where all our CSS rules are stored.
<style> tag inside the HTML file.
Here, the style tag within the HTML file will make all h1 elements in the file appear in deep pink.
Everything in a webpage is a box.
With CSS, we can control the size, spacing, and appearance of these boxes using the Box Model.
The Box Model consists of four main parts:
<div>, <p>, <h1>, <section><span>, <a>, <strong>, <em>In this example, if we apply both these rules to the same paragraph, the text will be red because the ID selector has higher specificity.
In this part we are going to edit the appearence of our website. For that purpose, we will be editing the style.css file in our repository.
First, let’s stop the content from getting so wide, by applying a max-width to <body>. We will specify that max-width in em, rem, or ch units, so that it scales with the font size. Experiment with the browser dev tools to find a good value for max-width. I used 100ch:
Now let’s center that content. We can do that by using the special value auto for the left and right margin. We can set both of these to the same value by using the margin-inline shorthand property.

But try resizing your window to be smaller than that max-width we set.
Our content is now touching the edges of the viewport, which makes it hard to read. One way to fix that is to add some padding to the content.

If you have used a <ul> element within your <nav>, you can tell the browser to ignore that <ul> and its <li> children for stylng by applying display: contents to them both, which prevents them from having any styling of their own.
First, let’s add a class="current" attribute to the a element of our current page, which will allow us to style it differently.
Let’s apply display: flex to the <nav> to enable Flexible box layout (Flexbox).
You will not notice any immediate difference, but we can now use Flexbox to control the layout of the children of <nav>. Apply flex: 1 to each of the <a> elements to make them take up the same amount of space.
text-decoration: none.color: inherit to make links use the same text color as their parent element.text-align: center.padding (for example 0.5em).margin-bottom to the whole <nav> to separate it from the content below.Apply a bottom border to the <nav> to visually separate it from the content. Give it a border-bottom-width of 1px, a border-bottom-style of solid, and a border-bottom-color of oklch(80% 3% 200) (some gray).
CSS Variables
The var() function is used to insert the value of a CSS variable. You can create variables with local or global scope, change the variables with JavaScript, and change the variables based on media queries.
A good way to use CSS variables is when it comes to the colors of your design. Instead of copy and paste the same colors over and over again, you can place them in variables.
To create a variable with global scope, declare it inside the :root selector. And to create a variable with local scope, declare it inside the selector that is going to use it.
Exercise for you:
Let’s style the current page link. Give it a thick bottom border (for example width of 0.4em), and either the same gray as the navigation bar border, or a lighter version. To counter the increase in height that the border adds, apply a reduced padding-bottom to that link.

Exercise for you: Accent color and hover styles
Define an accent color for your website, and store it in an --color-accent custom property (for example oklch(65% 50% 0)). Let’s use this accent color to style hovered navigation links (a:hover).
What styles would you have to add or modify to get something like this:

nav a.current {
border-bottom-width:0.4em;
border-bottom-style:solid;
border-bottom-color:oklch(80% 3% 200);
padding-bottom:0.1em;
font-weight: bold;
}Key elements of the from (the form controls<input>, <textarea>, <button>) have different sources. With the developer tool of inspection. All we need to make these use the same font as the rest of the page is font: inherit:

display: block to the form controls and labels to make them behave like block elements, i.e. insert line breaks before and afterwidth: 100% to the form controls to make them take up the whole width of their container (in other elements display: block does this too, but form controls are special)box-sizing: border-box to the form controls to make their width of 100% include their padding and bordermargin-block to the labels to add spacing before and after themThere is a better way to do something similar. CSS Grid: the crème de la crème of CSS layout methods. It may take some time to fully grok, but it is well worth it.
The core idea of CSS Grid is that we define a grid container (the element with display:grid), and then place its children in the grid (or descendants, through subgrid or display: contents).
Let’s remove the CSS you applied in the previous step, since we will not need it.
Starts by applying display: grid to the form. Note that you immediately see a change in the layout. We only need to define the actual constraints, and the browser will take care of the rest.
We need to define the columns, via grid-template-columns: auto 1fr.
auto means that the column will be as wide as its content, and1fr means that the column will take up the remaining space (similar to flex: 1).
<label for="email">Email: <input id="email" type="email" name="text_email"> </label>
<label for="subject">Subject: <input id="subject" type="text" name="text_subject"> </label>
<label for="body">Body: <textarea id="body" name="text_message"></textarea> </label>
Depending on how you organized the labels and inputs in your form, we will need to separate the texts from the inputs. For this, we will make the labels grid containers themselves (display: grid), but their grid is a subset of the form grid (grid-template-columns: subgrid).
The last piece of the puzzle, is that we need to make the labels (and the submit button) to span a whole row. We can use that by grid-column: 1 / -1; which means that the element will start at the first column and end at the last (-1) column.
At this point, your form should look about right. The last remaining touch is to add gap: 1em; to the form to add some spacing between the form controls.

We will use Emmet to generate some dummy content. Copy the following abbreviation:
Paste it in your projects/index.html file under the <h1> element, and expand it with Emmet (delete and re-add the last character, then hit Tab).
It’s generally a good practice to restrict images from getting too wide by applying max-width: 100% to them. You don’t need to only apply this on images within ‘.projects’, you can apply it to all images.
display: grid to .projects to make it a grid container.repeat(auto-fill, minmax(15em, 1fr)) for grid-template-columns to make the grid have as many columns as can fit in the container, each with a minimum width of 15em and a maximum width of 1fr (i.e. the remaining space).Exercise for you: Horizontal alignment with subgrid
The grid layout is looking good, but the content is not aligned. Some headings take up two lines, and the images are not aligned across columns.
Use subgrid on the <article> elements to make their contents align across columns. Tips:
<article> should span 3 rows without having to specify the starting row. We can do that by using grid-row: span 3;.margin: 0 on the <h2> to avoid excessive spacing.Note that we don’t have a clear information hierarchy. The default <h1> size is very close to the default <h2> size, violating the design principle of contrast. Make it significantly larger (e.g. 400% the body text). This is not specific to the projects page, but it’s the only one that currently has <h2> elements.
While we’re at it we can also add some good defaults for all headings (h1, h2, h3, h4, h5, h6), by applying line-height: 1.1 (we typically want their leading to be smaller than body text) and text-wrap: balance to prevent uneven lines.
You got your feet wet with CSS, experiment with it in a more freeform way by styling your CV/resume page.

Please complete this form
https://forms.gle/iyjhniGp4tJZMy949
