CSS Properties: How to specify the dashed border?
Solution:
HTML Code:
<!DOCTYPE html><!-- Declaration of HTML5 document type -->
<html>
<head>
<title>How to specify the dashed border</title><!-- Title of the HTML document -->
<style type="text/css">/* CSS style start*/
h1.dashed {
border-width: 5px; /* Setting border width to 5 pixels for elements with class "dashed" */
border-style: dashed; /* Setting border style to "dashed" for elements with class "dashed" */
Border-color: #CCD333 /* Setting border color to #CCD333 for elements with class "dashed" */
}
</style>
</head>
<body>
<h1 class="dashed">Dashed border style</h1><!-- Heading with class "dashed" -->
</body>
</html>
Explanation:
- This HTML document demonstrates how to specify a dashed border for an element using CSS.
- The CSS style block defines styling for elements with class "dashed".
- border-width: 5px; sets the border width to 5 pixels for elements with class "dashed".
- border-style: dashed; sets the border style to "dashed" for elements with class "dashed".
- border-color: #CCD333; sets the border color to #CCD333 (a shade of green) for elements with class "dashed".
- The HTML content consists of a <h1> heading with class "dashed", demonstrating the specified dashed border style.
Live Demo:
See the Pen border-style-dashed-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.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics