FAQ: Boundaries and Space - Create a Border

This community-built FAQ covers the “Create a Border” exercise from the lesson “Boundaries and Space”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Make a Website

FAQs on the exercise Create a Border

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hi there,
I just wanted to know if it is possible to assign an html element to 2 or more classes like this :

<h1 class="page-title" class="sub-ref">TUNDRA GALLERY</h1>

Above, the ‘h1’ element is assigned to two classes by the name “page-title” and “sub-ref”. I just want to know if this is allowed in HTML.
If it is allowed, then could someone explain how I could create a CSS selector for that particular element above.
Thank you.

Thankfully there is a tool for that:

https://validator.w3.org/nu/#textarea

i put this code in:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>test</title>
</head>
<body>
 <h1 class="page-title" class="sub-ref">TUNDRA GALLERY</h1>
</body>
</html>

otherwise we get a lot of other warnings/errors

as we can see, we get an error (duplicate attribute)

an element can have multiple classes, but only a single class attribute. Simply give the class attribute multiple values (space separated)

Thank you. So does that mean I can do something like this:

<h1 class="page-title" "sub-ref">TUNDRA GALLERY</h1>

Instead of :

<h1 class="page-title" class="sub-ref">TUNDRA GALLERY</h1>

Once again, Thank you for the quick reply.

almost, did you put that code through the validator/w3c tool i put in my previous reply? Then you would have know it was not correct

when we have an attribute with its value:

attribute="value"

the value is between the quotation marks. If we want to have multiple values, all values should be between the quotation marks (separated by spaces)

Sorry if I took to long to see this. Makes more sense to have values within the quotes.
Thank you.
So do you have any idea on how I could create a CSS selector for this particular element ? :

<h1 class="page-title sub-ref">TUNDRA GALLERY</h1>

Thank you once more.

that depends on the other elements in your code, if you truly want it be unique, use id