Basics of web development

CSS Borders

Easy
20 min

CSS borders refer to adding border lines to HTML elements. Borders are usually used in website design to highlight certain parts or provide visual separation between different elements. Using CSS, you can define the color, style, thickness, and rounding of the border.

Below are examples of using CSS border styles:

Determining the color of the border

You can specify the border color in CSS using the border-color property. For example, if you want to set the border color to red, you can write the following rule:

border-color: red;

Defining the style of the border

You can specify the style of the border by using the border-style property. For example, if you want to use a dotted line as the border, you can write the following rule:

border-style: dotted;

Determining the thickness of the border

You can specify the thickness of the border by using the border-width property. For example, if you want to set the border thickness to 2 pixels, you can write the following rule:

border-width: 2px;

Defining the rounding of the border

You can define the rounding of the border by using the border-radius property. For example, if you want to round the corners of the border by 5 pixels, you can write the following rule:

border-radius: 5px;

You can also combine these characteristics into one CSS rule. For example, if you want to create a green border that uses a double line, is 4 pixels thick, and has rounded corners, you can write the following rule:

border: 4px double green;
border-radius: 10px;

CSS delimiter lines allow you to create versatile and impressive designs for your website.

Practice

Kokeile itse!

Valitettavasti Replit-palvelu on muuttnut lennosta eikä enää anna suorittaa näitä koodeja suoraan selaimessa. Voit klikata alla olevaa "Open in Replit" linkkiä ja avata koodin Replit-palvelussa. Meillä on työn alla etsiä Replitille korvaaja.

hakatemia pro

Ready to become an ethical hacker?
Start today.

As a member of Hakatemia you get unlimited access to Hakatemia modules, exercises and tools, and you get access to the Hakatemia Discord channel where you can ask for help from both instructors and other Hakatemia members.