w3resource

CSS Properties: How to specify a solid border?

Go to Exercise page

Solution:

HTML Code:

<!DOCTYPE html><!-- Declaration of HTML5 document type -->
<html>
<head>
<title>How to specify a solid border</title><!-- Title of the HTML document -->
<style type="text/css">/* CSS style start*/
h1.solid {
border-width: 5px; /* Setting border width to 5 pixels for elements with class "solid" */
border-style: solid; /* Setting border style to "solid" for elements with class "solid" */
Border-color: #CFE339 /* Setting border color to #CFE339 for elements with class "solid" */
}
</style>
</head>
<body>
<h1 class="solid">Solid border style</h1><!-- Heading with class "solid" -->
</body>
</html>

Explanation:

  • This HTML document demonstrates how to specify a solid border for an element using CSS.
  • The CSS style block defines styling for elements with class "solid".
  • border-width: 5px; sets the border width to 5 pixels for elements with class "solid".
  • border-style: solid; sets the border style to "solid" for elements with class "solid".
  • border-color: #CFE339; sets the border color to #CFE339 (a shade of yellow-green) for elements with class "solid".
  • The HTML content consists of a <h1> heading with class "solid", demonstrating the specified solid border style.

Live Demo:

See the Pen border-style-solid-answer by w3resource (@w3resource) on CodePen.


See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
Yes Yes Yes Yes Yes

Go to Exercise page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.