Search code examples
cssstylesheet

Specify border-color for entire document in css


Isn't it possible to set the border-color once in the stylesheet to use as standard for all elements? -I've tried * {border-color: #FF8A8A;} in stylesheet.css and then put for example h2 {font-size:150%; border-bottom: solid 1px; }, but the border shows up black.

What am I doing wrong? Is it not possible to set the border-color like this? Or am I misunderstaning the use of * ?


Solution

  • Taken from W3School about border properties:

    If the border color is not set it is inherited from the color property of the element.

    Note: The "border-color" property does not work if it is used alone. Use the "border-style" property to set the borders first.

    So you the code would be something like this:

    * {
        border-style: solid;
        border-color: red;
    }
    
    div {
        border-width: 1px;
      }
    

    But I do not suggest this method because you are applying a border color to ALL elements on the page including BODY, HTML, all DIVs etc.