Menu

Log in

Sign up

From beginner to master of web design, coding, infrastructure operation, business development and marketing

  • COURSES
  • HTML & CSS Introduction
  • HTML & CSS Coding with AI
  • Linux Introduction
  • Docker Basics
  • Git & GitHub Introduction
  • JavaScript Coding with AI
  • Django Introduction
  • AWS Basics
  • Figma Introduction
  • SEO Tutorial for Beginners
  • SEO with AI
  • OTHERS
  • About
  • Terms of Service
  • Privacy Policy

© 2024 D-Libro. All Rights Reserved

HTML & CSS IntroductionChapter 13. CSS: Styling Borders and Drawing Lines

border-width

border-width

Adjusting Border Thickness with border-width

The border-width property is used to set the width (thickness) of borderlines. To show borderlines, you also need to set the border-style properly.

Property Values

You can set property values using length units or keywords.

Length units

  • px
  • em
  • rem
  • %
  • vw
  • vh

Keyword

  • medium (default)
  • thin
  • thick

Multiple Values

Like border-style and border-color, you can set multiple values to set border-width. The rules are the same as the ones for border-style and border-color. When you set only one value, the width is applied to all sides of the borderline. By setting multiple values, you can set different borderline widths for each side of the element.

Two values

  • The first value is applied to the top and bottom borders.
  • The second value is applied to the right and left borders.
border-width with two keywords (top&bottom  right&left)

Three values

  • The first value is applied to the top border.
  • The second value is applied to the right and left borders.
  • The third value is applied to the bottom border.
border-width with three keywords (top  right&left bottom)

Four values

Using four values, you can specify the width of each side of the borders. The property values are set based on clockwise order starting from the top.

  • The first value is applied to the top border.
  • The second value is applied to the right border
  • The third value is applied to the bottom border.
  • The fourth value is applied to the left border.
border-width with four keywords (top  right bottom left)

Practice

Objective:
Practice to set different border width with different number of values

1. Update the body section of the HTML file

Add the code below in the body section of the chapter13.html file. We are using the bg-border class which was defined in the previous practice.

In the code below, we are wrapping each set of item groups using the <div> element with the display and flex-wrap properties to structure the results. We'll explain these properties in detail later. For now, just copy and paste the code.

chapter13.html
<h2>Border Width</h2>
<div class="bg-border">Original</div>
<h3>Keyword</h3>
<div style="display: flex; flex-wrap: wrap;">
  <div class="bg-border" style="border-width: medium;">Medium</div>
  <div class="bg-border" style="border-width: thin;">Thin</div>
  <div class="bg-border" style="border-width: thick;">Thick</div>
</div>

<h3>Length</h3>
<div style="display: flex; flex-wrap: wrap;">
  <div class="bg-border" style="border-width: 5px;">5px</div>
  <div class="bg-border" style="border-width: 1rem;">1rem</div>
  <div class="bg-border" style="border-width: 1em;">1em</div>
  <div class="bg-border" style="border-width: 100%;">100%</div>
  <div class="bg-border" style="border-width: 1vw;">1vw</div>
  <div class="bg-border" style="border-width: 1vh;">1vh</div>
</div>

<h3>Multiple Values</h3>
<div style="display: flex; flex-wrap: wrap;">
  <div class="bg-border" style="border-width: thin thick;"><b>2 Values</b>: thin thick</div>
  <div class="bg-border" style="border-width: thin medium thick;"><b>3 Values</b>: thin medium thick</div>
  <div class="bg-border" style="border-width: 1px 5px 10px 15px;"><b>4 Values</b>: 1px 5px 10px 15px</div>
</div>
<hr>

2. Check the result with a browser

  • Open chapter13.html with a browser.
  • You can see how different border widths are set with multiple property values.

You can also check the sample result here (Demo Site).

link


You can also learn this topic offline. Click AmazonKindle.

More Topics to Explore

Scale() Function in CSS: Adjusting Scale of HTML Elements

Scale() Function in CSS: Adjusting Scale of HTML Elements

Chapter 6. Prototyping Interactive Designs with Figma

Chapter 6. Prototyping Interactive Designs with Figma

Ensuring Layout Consistency with flex-shrink

flex-shrink

App UI Design Elements

App UI Design Elements

Figma Quick Start Guide

Figma Quick Start Guide

Scale() Function in CSS: Adjusting Scale of HTML Elements

Scale() Function in CSS: Adjusting Scale of HTML Elements

Chapter 6. Prototyping Interactive Designs with Figma

Chapter 6. Prototyping Interactive Designs with Figma

Ensuring Layout Consistency with flex-shrink

flex-shrink

App UI Design Elements

App UI Design Elements

Figma Quick Start Guide

Figma Quick Start Guide

Tags:

Borderline

Border Width

HTML & CSS Introduction
Course Content

Chapter 1. Overview of Website Development

How Websites Work?

Designing, Building and Publishing Websites

Designing Websites

Building Websites – Frontend and Backend Coding

Web App vs. Website

Frontend Coding

Web Framework and CMS

Publishing Websites (Hosting Services)

Chapter 2. Preparing for Website Coding

Two Key Tools to Start Coding Websites

How Browsers Display Web Pages

File Name Rules

Website Directory Structure

Absolute Path vs. Relative Path

Chapter 3. HTML Basics

What Is HTML?

HTML Element

Attribute

HTML Document Structure

Layout Semantics

Heading and Paragraph Tag

Text-Level Semantics

Space, Line-break and Tag in Content

Comments in HTML Document

Chapter 4. HTML: Add Links and Images

Overview of Adding Links and Images

Embed Images – <img>

Image File Format

Add Hyperlinks – <a>

Add Hyperlinks to Images

Add Hyperlinks to Specific Location on Web Page

Link Tag – <link>

Script Tag – <script>

Chapter 5. HTML: Create Lists and Tables

Create Lists

Create Tables

Combine Table Cells

Chapter 6. HTML: Create Forms

Create Forms

Create Text Input Forms and Submit Button

Radio Button and Checkbox

Select Box

Labels

Auto Complete and Disabled

Chapter 7. Bridging HTML and CSS

Block Element vs. Inline Element

Nesting Elements – Parent Elements and Child Elements

Div vs. Span

Global Attribute – Class, ID and Style

Accordion – <Details> and <Summary>

Chapter 8. CSS Basics

What Is CSS?

CSS Syntax

Where To Type CSS?

CSS Basic Selectors

Descendant Selector

Inheritance

Specificity

Reset CSS

Browser Developer Tools for CSS

Comments in CSS Document

Chapter 9. Web Design Basics

Design Element Representation in HTML and CSS

Key Design Points by CSS

Length

Color Code – HEX and RGB

Color Theme

Chapter 10. CSS: Sizing and Spacing

CSS Box Model

width and height

padding

margin

Margin and Padding for Specific Side

margin: auto

box-sizing

Chapter 11. CSS: Styling Text and Images

Text Styling Properties

font-size

color

font-family

Web Font and Google Font

font-weight and font-style

text-decoration

line-height and letter-spacing

text-align

vertical-align

Styling Images

float: left and right

Chapter 12. CSS: Styling Backgrounds

background-color

background-image

background-size

background-repeat

background-position

background-attachment

background (Multiple Properties)

Chapter 13. CSS: Styling Borders and Drawing Lines

border-style

border-color

border-width

border-radius

Border (Multiple Properties)

Borders on Specific Side

Border Radius on Specific Side

Chapter 14. CSS: Layout – Key Concepts and Display Property

Layout Before and After

Layout Key Design Points

Display Property

inline, block and inline-block

display: none

Chapter 15. CSS: Layout – Flex Box

Flex Box – display: flex

flex-direction

Main Axis and Cross Axis

flex-wrap

justify-content

align-items

align-content

align-self

flex-grow

flex-shrink

flex-basis

margin: auto with Flex Box

Inline Flex Box

Nested Flex Box

Chapter 16. CSS: Styling Lists

List Styling Properties

list-style-type

list-style-image

list-style-position

Chapter 17. Creating and Styling Components

Components and Layout

Buttons

Cards

Top Bar

Footer and Bottom Bar

Chapter 18. Completing Website Development

Website Structure Design

Live Server

Home (Landing) Page Development

Main (List) Page Development

Content (Detail) Page Development

Chapter 19. Publishing Websites

Key Steps to Publish Websites

Domain and DNS Server

Favicon

GitHub Pages

Chapter 20. Supplemental Topics

Horizontal Rule – <hr>

Line Break – <br>

Reserved Characters and HTML Entities

Non-breaking Space – &nbsp;

Chapter 1. Overview of Website Development

How Websites Work?

Designing, Building and Publishing Websites

Designing Websites

Building Websites – Frontend and Backend Coding

Web App vs. Website

Frontend Coding

Web Framework and CMS

Publishing Websites (Hosting Services)

Chapter 2. Preparing for Website Coding

Two Key Tools to Start Coding Websites

How Browsers Display Web Pages

File Name Rules

Website Directory Structure

Absolute Path vs. Relative Path

Chapter 3. HTML Basics

What Is HTML?

HTML Element

Attribute

HTML Document Structure

Layout Semantics

Heading and Paragraph Tag

Text-Level Semantics

Space, Line-break and Tag in Content

Comments in HTML Document

Chapter 4. HTML: Add Links and Images

Overview of Adding Links and Images

Embed Images – <img>

Image File Format

Add Hyperlinks – <a>

Add Hyperlinks to Images

Add Hyperlinks to Specific Location on Web Page

Link Tag – <link>

Script Tag – <script>

Chapter 5. HTML: Create Lists and Tables

Create Lists

Create Tables

Combine Table Cells

Chapter 6. HTML: Create Forms

Create Forms

Create Text Input Forms and Submit Button

Radio Button and Checkbox

Select Box

Labels

Auto Complete and Disabled

Chapter 7. Bridging HTML and CSS

Block Element vs. Inline Element

Nesting Elements – Parent Elements and Child Elements

Div vs. Span

Global Attribute – Class, ID and Style

Accordion – <Details> and <Summary>

Chapter 8. CSS Basics

What Is CSS?

CSS Syntax

Where To Type CSS?

CSS Basic Selectors

Descendant Selector

Inheritance

Specificity

Reset CSS

Browser Developer Tools for CSS

Comments in CSS Document

Chapter 9. Web Design Basics

Design Element Representation in HTML and CSS

Key Design Points by CSS

Length

Color Code – HEX and RGB

Color Theme

Chapter 10. CSS: Sizing and Spacing

CSS Box Model

width and height

padding

margin

Margin and Padding for Specific Side

margin: auto

box-sizing

Chapter 11. CSS: Styling Text and Images

Text Styling Properties

font-size

color

font-family

Web Font and Google Font

font-weight and font-style

text-decoration

line-height and letter-spacing

text-align

vertical-align

Styling Images

float: left and right

Chapter 12. CSS: Styling Backgrounds

background-color

background-image

background-size

background-repeat

background-position

background-attachment

background (Multiple Properties)

Chapter 13. CSS: Styling Borders and Drawing Lines

border-style

border-color

border-width

border-radius

Border (Multiple Properties)

Borders on Specific Side

Border Radius on Specific Side

Chapter 14. CSS: Layout – Key Concepts and Display Property

Layout Before and After

Layout Key Design Points

Display Property

inline, block and inline-block

display: none

Chapter 15. CSS: Layout – Flex Box

Flex Box – display: flex

flex-direction

Main Axis and Cross Axis

flex-wrap

justify-content

align-items

align-content

align-self

flex-grow

flex-shrink

flex-basis

margin: auto with Flex Box

Inline Flex Box

Nested Flex Box

Chapter 16. CSS: Styling Lists

List Styling Properties

list-style-type

list-style-image

list-style-position

Chapter 17. Creating and Styling Components

Components and Layout

Buttons

Cards

Top Bar

Footer and Bottom Bar

Chapter 18. Completing Website Development

Website Structure Design

Live Server

Home (Landing) Page Development

Main (List) Page Development

Content (Detail) Page Development

Chapter 19. Publishing Websites

Key Steps to Publish Websites

Domain and DNS Server

Favicon

GitHub Pages

Chapter 20. Supplemental Topics

Horizontal Rule – <hr>

Line Break – <br>

Reserved Characters and HTML Entities

Non-breaking Space – &nbsp;