InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

CSS properties

  • CSS3 flexbox
  • all
  • animation
  • background-color
  • background-image
  • border
  • border-color
  • border-radius
  • border-style
  • border-width
  • bottom
  • box-shadow
  • box-sizing
  • calc function
  • clip
  • color
  • color value currentColor
  • color values
  • cursor
  • float
  • font
  • font-family
  • font-size
  • font-style
  • font-variant
  • font-weight
  • generated content
  • left
  • letter-spacing
  • line-height
  • list-style
  • list-style-image
  • list-style-position
  • list-style-type
  • margin
  • max-height
  • max-width
  • min-height
  • min-width
  • opacity
  • outline
  • outline-color
  • outline-style
  • outline-width
  • overflow
  • padding
  • pointer-events
  • position
  • resize
  • right
  • text-align
  • text-decoration
  • text-indent
  • text-overflow
  • text-shadow
  • text-transform
  • top
  • transform
  • transition
  • transition-delay
  • transition-duration
  • transition-property
  • transition-timing-function
  • visibility
  • white-space
  • word-break
  • word-spacing
  • word-wrap/overflow-wrap
  • z-index
 
  • Home
  • > Tutorials
  • > CSS
  • > CSS properties

CSS border radius and round corners examples

on Feb 6, 2016

CSS3 border-radius property can be used to make corners round of a block element. Border radius can have upto 4 values. Here is how a simple div with border-radius look like:

css-border-radius-example

CSS property border-radius

CSS version: CSS 3
Value: [length | percentage]{1,4}
Initial: 0 (individual properties)
Applies to: all elements
Inherited: no
Animatable: yes
Few points to note about border-radius property:

  1. border-radius 4 values: First value is for top-left radius, 2nd is for top-right, third is for bottom right and 4th is for bottom left.
  2. border-radius 3 values: Similar to 4 values situation except that 2nd value applies to bottom left corner also.
  3. border-radius 2 values: First value is for top-left and bottom right corner. 2nd value is for other two corners.
  4. border-radius 1 value: It applies to all 4 corners.
  5. Alternatively we can also use border-top-left-radius, border-top-right-radius, border-bottom-right-radius and border-bottom-left-radius. This may be useful in case we want to override one value defined in some other style sheet.

Example – border-radius with one value

<style type="text/css" media="screen">
.foo {
 width:100px; height:100px;
 background-color: lightgreen;
 border: 5px solid gray;
 border-radius: 20px;
}
</style>
<div class="foo"></div>
refresh done
try it online

Example – border-radius with two values

<style type="text/css" media="screen">
.foo {
 width:100px; height:100px;
 background-color: lightgreen;
 border: 5px solid gray;
 border-radius: 20px 40px;
}
</style>
<div class="foo"></div>
refresh done
try it online

Example – border-radius with 4 values

<style type="text/css" media="screen">
.foo {
 width:100px; height:100px;
 background-color: lightgreen;
 border: 5px solid gray;
 border-radius: 10px 20px 30px 40px;
}
</style>
<div class="foo"></div>
refresh done
try it online

Example – border-top-left-radius, border-top-right-radius, border-bottom-right-radius, border-bottom-left-radius

<style type="text/css" media="screen">
.foo {
 width:100px; height:100px;
 background-color: lightgreen;
 border: 5px solid gray;
 border-top-left-radius: 10px;
 border-top-right-radius: 20px;
 border-bottom-right-radius: 30px;
 border-bottom-left-radius: 40px;
}
</style>
<div class="foo"></div>
refresh done
try it online

Related

  • CSS border - define border properties of an element
  • CSS border-width - set element border width of four sides
  • CSS border-color - define color of four borders
  • CSS border-style tutorial and examples

Specification and Browser compatibility

SpecificationStatusCategories
CSS3 Border-radius (rounded corners)W3C Candidate RecommendationCSS3
Desktop
ChromeFirefoxIEEdgeSafariOpera
Yes 5+ Yes 4+ Yes 9+ Yes 12+ Yes 5+ Yes 10.5+
Mobile
Android ChromeAndroid FirefoxiOS SafariIE MobileOpera Mobile
Yes 47+ Yes 44+ Yes 4.0-4.1+ Yes 10+ Yes 11+
source: caniuse.com

Suggested posts:

  1. HTML ol tag
  2. Install nginx and php in docker ubuntu container
  3. CSS border-width – set element border width of four sides
  4. CSS list-style – shorthand for list marker type, image and position
  5. How to create CSS triangles or arrow heads
  6. CSS right
  7. CSS flexbox – display flex and inline-flex
  8. jQuery – get checkbox value and checked state
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged CSS, CSS properties, CSS3, Tutorials, Web Development
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress