CSS Properties: How to specify a medium 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 specify a medium border</title><!-- Sets the title of the HTML document -->
<style type="text/css"> /* Begins a CSS style block */
h1.xyz { /* Defines a CSS rule for h1 elements with class "xyz" */
border-style: solid; /* Sets the border style to solid */
border-width: medium; /* Sets the border width to medium */
}
</style><!-- Ends the CSS style block -->
</head><!-- Ends the head section of the HTML document -->
<body><!-- Contains the content of the HTML document -->
<p>w3resource Tutorial</p><!-- Displays a paragraph with the text "w3resource Tutorial" -->
<h1 class="xyz">Medium border</h1><!-- Displays an h1 element with class "xyz" and the text "Medium border" -->
<p><b>Note:</b> The border-width property does not work alone.</p><!-- Displays a note about the border-width property -->
</body><!-- Ends the body section of the HTML document -->
</html><!-- Ends the HTML document -->
Explanation:
- This HTML document sets up a basic webpage.
- The <!DOCTYPE html> declaration specifies the document type as HTML.
- The <html> element is the root element of the HTML document.
- The <head> section contains metadata about the HTML document, such as the title.
- The <title> element sets the title of the HTML document.
- The <style> element begins a CSS style block.
- Inside the CSS block, a rule is defined for <h1> elements with the class "xyz".
- The CSS rule sets the border style to solid and the border width to medium for elements with the class "xyz".
- The <body> section contains the content of the HTML document.
- A paragraph with the text "w3resource Tutorial" is displayed.
- An <h1> element with the class "xyz" and the text "Medium border" is displayed.
- A note is provided about the border-width property not working alone to specify all four borders.
Live Demo:
See the Pen border-medium-width-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