CSS Properties: How to set the style of the top border?
Solution:
HTML Code:
<!DOCTYPE html><!-- Declares the document type as HTML -->
<html><!-- Root element of the HTML document -->
<head><!-- Contains metadata about the HTML document -->
<title>How to set the style of the top border</title><!-- Sets the title of the HTML document -->
<style type="text/css"> /* Begins a CSS style block */
h1 {border-style: solid;} /* Defines a default CSS rule for h1 elements to have a solid border style */
h1.abc {border-top-style: none;} /* Sets the top border style of h1 elements with class "abc" to none */
h1.dotted {border-top-style: dotted;} /* Sets the top border style of h1 elements with class "dotted" to dotted */
h1.dashed {border-top-style: dashed;} /* Sets the top border style of h1 elements with class "dashed" to dashed */
h1.solid {border-top-style: solid;} /* Sets the top border style of h1 elements with class "solid" to solid */
h1.double {border-top-style: double;} /* Sets the top border style of h1 elements with class "double" to double */
h1.groove {border-top-style: groove;} /* Sets the top border style of h1 elements with class "groove" to groove */
h1.ridge {border-top-style: ridge;} /* Sets the top border style of h1 elements with class "ridge" to ridge */
h1.inset {border-top-style: inset;} /* Sets the top border style of h1 elements with class "inset" to inset */
h1.outset {border-top-style: outset;} /* Sets the top border style of h1 elements with class "outset" to outset */
h1.hidden {border-top-style: hidden;} /* Sets the top border style of h1 elements with class "hidden" to hidden */
h1.initial {border-top-style: initial;} /* Sets the top border style of h1 elements with class "initial" to initial */
</style><!-- Ends the CSS style block -->
</head><!-- Ends the head section of the HTML document -->
<body><!-- Contains the content of the HTML document -->
<h1 class="none">No border style</h1><!-- Displays an h1 element with no border style -->
<h1 class="dotted">A dotted border style</h1><!-- Displays an h1 element with a dotted border style -->
<h1 class="dashed">A dashed border style</h1><!-- Displays an h1 element with a dashed border style -->
<h1 class="solid">A solid border style</h1><!-- Displays an h1 element with a solid border style -->
<h1 class="double">A double border style</h1><!-- Displays an h1 element with a double border style -->
<h1 class="groove">A groove border style</h1><!-- Displays an h1 element with a groove border style -->
<h1 class="ridge">A ridge border style</h1><!-- Displays an h1 element with a ridge border style -->
<h1 class="inset">An inset border style</h1><!-- Displays an h1 element with an inset border style -->
<h1 class="outset">An outset border style</h1><!-- Displays an h1 element with an outset border style -->
<h1 class="hidden">A hidden border style</h1><!-- Displays an h1 element with a hidden border style -->
<h1 class="initial">A initial border style, like as no border</h1><!-- Displays an h1 element with an initial border style, like no border -->
</body><!-- Ends the body section of the HTML document -->
</html><!-- Ends the HTML document -->
Explanation:
- The HTML document structure includes essential elements such as html, head, title, style, and body.
- CSS rules are defined to specify different border styles for h1 elements based on their classes.
- Each CSS rule targets specific classes to set the border-top-style property to achieve different border styles.
- Comments were added below the code line as requested.
Live Demo:
See the Pen border-top-style-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
Supported browser
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/html-css-exercise/css-properties/border-top-style-answer.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics