Table of Contents
Border attribute
Example
Specify double borders
Specify double border attributes
This has double styled border with thinnest border
This has double styled border applied with slightly thick border than previous box.
This has double styled border applied with the thickest border
in conclusion
Home Web Front-end CSS Tutorial How to specify double borders using CSS?

How to specify double borders using CSS?

Sep 05, 2023 pm 10:45 PM

How to specify double borders using CSS?

We know that CSS is a rule-based style sheet language used to design and customize web pages. They are used to specify how html elements are formatted and displayed on the screen. One style we often use is to add or modify the border of an element. This can be achieved by using the CSS 'border property'.

Border attribute

"Border" is an abbreviated way of specifying a border around an element, by specifying the border width, style, and color. Therefore, we can say that the border property actually consists of the following three properties.

  • Border Color - It sets the color of the border, falling back to the current color if not present.

  • Border-style − It specifies the border style being used, falling back to none if it does not exist.

  • Border-width - This determines the thickness of the border, default is "medium"

We can also specify the width, style and color of each side of the border individually. Note that it is not an inheritable property, which means that if the container element has a border around it, the child elements will not have a border unless specified.

We can use one, two or all three properties to specify the border. Any value we don't specify will have its default/initial value as its value.

Example

An example of a border using all three properties is given below.

<!DOCTYPE html>
<html lang="en">
<head>
   <title>Border and its styling</title>
   <style>
      div {
         width: 100%;
         height: 200px;
         align-content: center;
         justify-content: center;
      }
      #box1 {
         background-color: antiquewhite;
         border: 2px solid black;
      }
      #box2 {
         background-color: aquamarine;
         border: dashed blue;
      }
      #box3 {
         background-color: blanchedalmond;
         border: red;
      }
      #box4 {
         background-color: beige;
         border: 1px rebeccapurple;
      }
   </style>
</head>
<body>
   <div id="box1">Black 2px solid border</div>
   <div id="box2">Blue dashed border</div>
   <div id="box3">No visible border</div>
   <div id="box4">No visible border</div>
</body>
</html>
Copy after login

We can see that each style has a different effect on the border of the element.

Specify double borders

Now that we have learned the basics of using the border property in CSS, we will start solving the question "How to specify a double border using CSS". Let’s take a brief look at what the border-style property is, what you can do with it, and how to use it to solve our problem.

Specify double border attributes

We have discussed above that the border-style attribute controls the border style applied to elements in CSS. The border-style attribute is used to control how the border line is displayed on the web page. This is also a shorthand property, consisting of the bottom, left, right and top style properties.

We can specify the border-style attribute using one, two, three, or all four values.

  • If we only use one value, this property has the effect of applying the same style to all border lines.

  • When we use two values, the first style will be applied to the top and bottom of the border, while the second style will be applied to the left and right parts of the border.

  • When three values ​​are specified, the first style will be applied to the top, the second style will be applied to the left and right sections, and the last style will be applied to the bottom.

  • If we specify all four values, the order in which the styles are applied will be top, right, bottom, and left (i.e. clockwise from top).

Now let's see what possible values ​​we can give to this property.

  • No

  • hide

  • Dotted

  • dotted line

  • solid

  • pair

  • Groove

  • Ridge

  • insert

  • The Chinese translation of
  • Outset

  • is:
  • starting point

After looking at these values, we can see that by using "double" as the value of the border-style property, we can achieve the effect of double borders.

Example

An example of using the border-style attribute to specify a double border is given below.

<!DOCTYPE html>
<html>
<head>
   <style>
      body {
         background-color: beige;
         text-align: center;
      }
      h1.doubleApplied {
         border-width: 5px;
         border-style: double;
         Border-color: blue;
      }
      h1.double2Applied {
         border-width: 15px;
         border-style: double;
         Border-color: blue;
      }
      h1.double3Applied {
         border-width: 20px;
         border-style: double;
         Border-color: blue
      }
   </style>
</head>
<body>
   <h1 id="This-has-double-styled-border-with-thinnest-border">This has double styled border with thinnest border</h1>
   <h1 id="This-has-double-styled-border-applied-with-slightly-thick-border-than-previous-box">This has double styled border applied with slightly thick border than previous box.</h1>
   <h1 id="This-has-double-styled-border-applied-with-the-thickest-border">This has double styled border applied with the thickest border</h1>
</body>
</html>
Copy after login

We can see that by using double as the value, all elements have a double border of varying thickness around them.

in conclusion

In summary, specifying double borders using CSS is a simple task. You just need to use the border-style attribute and set it to double. This will draw two lines on each side of the element, giving your page a unique and stylish look. Additionally, you can use other properties such as "border-width" and "border-color" to customize the color, size, and other properties of these borders. With practice, you'll soon be able to create stunning designs with borders.

The above is the detailed content of How to specify double borders using CSS?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Vue 3 Vue 3 Apr 02, 2025 pm 06:32 PM

It&#039;s out! Congrats to the Vue team for getting it done, I know it was a massive effort and a long time coming. All new docs, as well.

Building an Ethereum app using Redwood.js and Fauna Building an Ethereum app using Redwood.js and Fauna Mar 28, 2025 am 09:18 AM

With the recent climb of Bitcoin’s price over 20k $USD, and to it recently breaking 30k, I thought it’s worth taking a deep dive back into creating Ethereum

Can you get valid CSS property values from the browser? Can you get valid CSS property values from the browser? Apr 02, 2025 pm 06:17 PM

I had someone write in with this very legit question. Lea just blogged about how you can get valid CSS properties themselves from the browser. That&#039;s like this.

A bit on ci/cd A bit on ci/cd Apr 02, 2025 pm 06:21 PM

I&#039;d say "website" fits better than "mobile app" but I like this framing from Max Lynch:

Stacked Cards with Sticky Positioning and a Dash of Sass Stacked Cards with Sticky Positioning and a Dash of Sass Apr 03, 2025 am 10:30 AM

The other day, I spotted this particularly lovely bit from Corey Ginnivan’s website where a collection of cards stack on top of one another as you scroll.

Using Markdown and Localization in the WordPress Block Editor Using Markdown and Localization in the WordPress Block Editor Apr 02, 2025 am 04:27 AM

If we need to show documentation to the user directly in the WordPress editor, what is the best way to do it?

Comparing Browsers for Responsive Design Comparing Browsers for Responsive Design Apr 02, 2025 pm 06:25 PM

There are a number of these desktop apps where the goal is showing your site at different dimensions all at the same time. So you can, for example, be writing

Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Why are the purple slashed areas in the Flex layout mistakenly considered 'overflow space'? Apr 05, 2025 pm 05:51 PM

Questions about purple slash areas in Flex layouts When using Flex layouts, you may encounter some confusing phenomena, such as in the developer tools (d...

See all articles