back

</>CodeWithRahul

More
  • Home
  • Cources
  • Tutorials
  • Tutorials
  • Projects
  • Notes
  • Contact
  • Work With Us
  • HTML
  • CSS
  • JAVASCRIPT
  • CC++
  • PHP
  • PYTHON
  • REACT JS
  • DSA

</>Code With Rahul

Create an account
  • INTRODUCTION
    • Information & History
    • Your first CSS Website
    • How CSS Works?
    • Ways to add CSS
    • CSS Selectors
    • CSS Comments
  • CSS Properties
    • CSS colors
    • CSS backgrounds
    • CSS Borders
    • CSS Image
    • CSS Videos Embedding
    • CSS Fonts
    • CSS Text Styling
    • CSS Padding
    • CSS Margin
    • CSS Hover
    • CSS Links
    • CSS Combinators
    • CSS Pseudo Classes
    • CSS Buttons
    • CSS Overflow
    • CSS Float
    • CSS !Important
    • CSS Maths Function
    • CSS Size
    • CSS Positioning
    • CSS Z-index
    • CSS Forms
    • CSS Navigation
  • CSS Designing
    • CSS Display
    • CSS FlexBox
    • CSS Grid
    • CSS Meida Queries
  • CSS Advance Topics
    • CSS CSS 2D
    • CSS Transform
    • CSS Transition
    • CSS Border Image
    • CSS Gradients
    • CSS Inherit
    • CSS Shadows
    • CSS ToolTip Text
    • CSS Border Image
    • CSS Masking
    • CSS Pagination
    • CSS Meida Queries Advance
    • CSS Animation
  • CSS FAGS
    • CSS Questions

    CSS Borders

    Border property helps in creating borders around the text. Various properties in it are discussed in this module.

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Different type of Borders</title>
        <style>
            p.none {border-style: none;}
            p.hidden {border-style: hidden;}
            p.dotted {border-style: dotted;}
            p.dashed {border-style: dashed;}
            p.double {border-style: double;}
            p.inset {border-style: inset;}
            p.outset {border-style: outset;}
            p.ridge {border-style: ridge;}
            p.groove {border-style: groove;}
            p.solid {border-style: solid;}
        </style>
    </head>
    <body>
        <p class="none">This is border none</p>
        <p class="hidden">This is border hidden</p>
        <p class="dotted">This is border dotted</p>
        <p class="dashed">This is border dashed</p>
        <p class="double">This is border double</p>
        <p class="inset">This is border inset</p>
        <p class="outset">This is border outset</p>
        <p class="ridge">This is border ridge</p>
        <p class="groove">This is border groove</p>
        <p class="solid">This is border solid</p>
    </body>
    </html>
                                

    Output

    all borders Result

    Border Width

    It sets the width of the border in pixels (or there are key values too like medium, thin, thick)

    Example :-

    <style>
        border-style: solid;
        border-width: thin;
    </style>
                                

    Output

    border width property

    You can assign values according to your wish or use medium/thick instead of thin if you wish to.

    CSS Border Color

    This property assigns colours to the border of the text. We’ve already discussed in the CSS colours module different ways to provide the colour value like rgb, hsl, etc.

    Example :-

    <style>
        border-style: solid;
        border-color: #f23;
        padding: 20px;
    </style>
                                

    Output

    border Color property

    CSS Border Radius

    Rounded borders around buttons look classic, which can be achieved by border-radius property.

    Example :-

    <style>
        border-style: solid;
        border-color: #f23;
        border-radius: 30px;
        padding: 20px;
    </style>
                                

    Output

    border Radius property

    In this example, we gave a single value to the property; but if you want to choose for each edge you can provide two values, three values and four values which resemble the top-left corner, top-right corner, bottom-left corner, and bottom-right corner.

    Apart from that, you can control the outer radii as well using “%” or em (relative font size unit in CSS, we’ll discuss it later in depth).

    Example :-

    <style>
        border-style: solid;
        border-radius:20rem 10rem;
    </style>
                                
    border Radius property

    Border Collapse & Spacings

    CSS has these two properties too, to help the user select the spacing between two borders but before you go testing them, this property requires a table.

    Which of course we’ll look at later. For now, you can know the syntax of both properties.

    Example :-

    <style>
        border-collapse: value;
        border-spacing: value;
    </style>
                                

    Border Shorthand

    Just like background shorthands, there exists a border shorthand which takes three properties: width, style and colour.

    Example:

    <style>
        border: solid red 10px;
    </style>
                                
    border Shorthand
    Owner of this WebPage Image

    CodeWithRahul

    Copyright © 2023 CodeWithRahul.com