The Wayback Machine - https://web.archive.org/web/20251205184806/https://www.geeksforgeeks.org/css/how-to-specify-no-border-in-css/
Open In App

How to Specify no Border in CSS ?

Last Updated : 28 Jun, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

When designing web pages, borders can be useful for highlighting elements or defining structure, but sometimes, you may want to remove them entirely for a cleaner or more modern look. In CSS, specifying no border is a straightforward process that helps you eliminate borders from HTML elements such as input fields, buttons, divs, and tables.

Let, go through some common methods to specify no Border in CSS :

1. Using border: none;

The border: none; property removes all borders from an element.

HTML
<html>
<head>
<style>
   .box {
            width: 200px;
            height: 100px;
            background-color: lightblue;
            border: 2px solid black;
        }
        .box-no-border {
            border: none;
        }
        </style>
</head>
<body>
<div class="box">
   With Border
        </div>
<div class="box box-no-border">
   No Border
        </div>
</body>
</html>

Code Overview:

  • The .box class initially applies a black border of 2px.
  • The .box-no-border class removes the border by setting border: none;.

2. Using border-width: 0

Set border-width: 0; to effectively remove the border while retaining other border styles (like color).

HTML
<html>
<head>
    <style>
        .box {
            width: 200px;
            height: 100px;
            background-color: lightcoral;
            border: 2px solid black;
        }
        .box-no-border {
            border-width: 0;
        }
    </style>
</head>
<body>
    <div class="box">With Border</div>
    <div class="box box-no-border">No Border</div>
</body>
</html>

Code Overview:

  • The .box class applies a black border of 2px.
  • The .box-no-border class reduces the border width to 0, effectively hiding the border.

3. Using border-style: none

Applying border-style attribute value to none removes the border by setting its style to none.

HTML
<html>
<head>
    <style>
        .box {
            width: 200px;
            height: 100px;
            background-color: lightgreen;
            border: 2px solid black;
        }
        .no-border {
            border-style: none;
        }
    </style>
</head>
<body>
    <div class="box">With Border</div>
    <div class="box no-border">No Border</div>
</body>
</html>

Code Overview:

  • The .box class applies a 2px solid black border.
  • The .no-border class sets border-style: none;, removing the border's style and making it invisible

Note: If you remove borders in CSS it will help you to make your website look cleaner. You can also use border: none; or remove borders from just one side. Be careful with form elements - removing borders or outlines can remove accessibility.


How to specify no border in CSS ?

Explore