Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
In this lesson, we'll learn about how you can apply styles to specific "classes" within your HTML files. We'll take a look at the text-align, border, and border-radius CSS attributes, and also explore some of the useful online resources available to help developers pick and choose styles and design rules.
Developers use digital resources on a daily basis to locate hints, tips, and tricks to speed up their job. There's a whole bunch of great resources available to help you pick and choose the styles and attributes you use during your development process, as well as heaps of helpful forums and communities to keep up to date with new features as they are introduced!
With new rules being added to CSS every year, there's really never been a more exciting time to get started with web development.
In this lesson, we practiced writing and applying styles to classes. Instead of limiting our stylesheet to specific tags or elements, we can create custom names or shortcuts, and apply them to any element on the page. This means that we can apply a style to just one element on a page, without having to style them all at once.
Let's take a look at an example below. We're preparing our shopping list for the week, but...uh oh! Our milk has gone off. We want this to stand out in our shopping list, so we've applied a class to the <li>
tag and assigned it the name value "urgent"
.
<h1> My Shopping List! </h1>
<ul>
<li> Eggs </li>
<li class="urgent"> Milk </li>
<li> Bread </li>
</ul>
To make our urgent class stand out on our shopping list, we've used the .urgent
class selector in our stylesheet and applied a red color to the text for all elements in our HTML that share this tag.
.urgent {
color: red;
}
Now when we view our shopping list, the text for "Milk" will really stand out from the rest! As this is the only element on the page that has a style applied to it, all other <li>
elements will only display their default styling.
New Terms:
- class - A global attribute that can be applied to any HTML element. Classes allow CSS and JavaScript to select and style specific elements or groups or elements with consistent themes, colors, or other interactive qualities.
Further Reading:
References
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up