The border property is used to define the border properties for an element. It is a shorthand for border-width, border-style and border-color.
Syntax
The syntax of CSS border property is as follows −
Selector { border: /*value*/ }
Example
The following examples illustrate CSS border property −
<!DOCTYPE html> <html> <head> <style> img { margin-top: 14px; margin-left: 30px; border: 2px solid orange; box-shadow: 0 0 12px 1px black; } #demo { border: 4px dotted magenta; } </style> </head> <body> <img src="https://www.tutorialspoint.com/swing/images/swing-mini-logo.jpg"> <img id="demo" src="https://www.tutorialspoint.com/scala/images/scala-mini-logo.jpg"> </body> </html>
Output
This gives the following output −
Example
<!DOCTYPE html> <html> <head> <style> table { margin: 1em; border: 3px dashed green; } td { font-size: 24px; border: 2px double navy; } </style> </head> <body> <table> <tr> <td>This</td> <td>text</td> </tr> <tr> <td>is</td> <td>demo</td> </tr> </table> </body> </html>
Output
This gives the following output −