Skip to main content

Exercise 19

  • Create the following folder/file structure:
/ex_19
|-- index.html

index.html

  • Create a basic HTML document
  • Create a script tag on the document head element
  • Add the following html code
<!DOCTYPE html>
<html lang="en">
<head>
<title>Setting attributes</title>
<style>
.bold {
font-weight: bold;
}

.striked {
text-decoration: line-through;
}
</style>
</head>
<body>
<h1 id="main">Playing with attributes</h1>
<div name="divy">
We have more control over our documents as we learn about JavaScript and
DOM elements!!!
</div>
</body>
</html>
  • Select the h1 and div element and assign them to a new variable
  • If any of these elements has attributes then add the striked class to both of them
  • Else add the bold class
  • Remove the name attribute from the div element (use the web console elements tab to see the result)