Lesson: HTML5 and CSS
Add Borders Around your Elements
CSS borders have properties like style
, color
and width
For example, if we wanted to create a red, 5 pixel border around an HTML element, we could use this class:
<style>
.thin-red-border {
border-color: red;
border-width: 5px;
border-style: solid;
}
</style>
Create a class called thick-green-border
that puts a 10-pixel-wide green border with a style of solid
around an HTML element, and apply that class to your cat photo.
Remember that you can apply multiple classes to an element by separating each class with a space within its class
attribute. For example:
<img class="class1 class2">
Your
img
element should have the class smaller-image
. Your
img
element should have the class thick-green-border
. Give your image a border width of
10px
. Give your image a border style of
solid
. The border around your
img
element should be green. href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css"
.red-text {
color: red;
}
h2 {
font-family: Lobster, Monospace;
}
p {
font-size: 16px;
font-family: Monospace;
}
.smaller-image {
width: 100px;
}
class="red-text"CatPhotoApp
class="smaller-image" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. "
class="red-text"Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the
grass sniff.
class="red-text"Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.
Correct, congratulations!
Next problem: Add Rounded Corners with a Border Radius
Try again
The content on this page is licensed under Attribution-ShareAlike 4.0 International. Original authors: freeCodeCamp, the content was modified.