Home > Web Front-end > CSS Tutorial > How to set border size in css

How to set border size in css

下次还敢
Release: 2024-04-25 18:57:14
Original
802 people have browsed it

In CSS, use the border-width property to set the border size. The available units are px, em, pt, cm or %. You can set a uniform width for all borders, or set the width individually for specific borders.

How to set border size in css

CSS Setting Border Size

Setting border size in CSS is a simple process that requires usingborder-width attribute. The value of this property can be in the following units:

  • px (pixels)
  • em (relative to the current font size)
  • pt (points)
  • cm (centimeters)
  • % (relative to parent element width)

To set the width of all borders, you can use the border-width attribute, followed by A border size value, such as:

<code class="css">border-width: 2px;</code>
Copy after login

To set the width of a specific border individually, you can use border-top-width, border-right-width, border-bottom-width and border-left-width attributes, and add a border size value after them, such as:

<code class="css">border-top-width: 10px;
border-right-width: 5px;
border-bottom-width: 2px;
border-left-width: 8px;</code>
Copy after login

Example:

The following CSS code sets the element's border size to 5 pixels:

<code class="css">div {
  border-width: 5px;
}</code>
Copy after login

The following CSS code sets the element's top border size to 10 pixels and the right border size to 5 pixels, Set the bottom border size to 2 pixels and the left border size to 8 pixels:

<code class="css">div {
  border-top-width: 10px;
  border-right-width: 5px;
  border-bottom-width: 2px;
  border-left-width: 8px;
}</code>
Copy after login

The above is the detailed content of How to set border size in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template