Horizontal rule/line beneath each

heading in CSS

后端 未结 6 704
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 09:01

I am trying to place a 100% horizontal line (rule) automatically beneath every instance of an

 

header tag using CSS.

Example

6条回答
  •  广开言路
    2021-02-05 09:44

    You should use the border-bottom CSS property.

    For HTML, use the below code:

    Introduction

    For CSS, use the below code:

    h1
    {
        border-bottom:1px solid #CCC;
        padding-bottom:3px;
    }
    

    In case, you want to use the float:left, float:right properties, then you have to use width:100% property also. padding-bottom is to optionally give some space between the text and horizontal line.

    h1
    {
        border-bottom:1px solid #CCC;
        float:left;
        width:100%;
        padding-bottom:3px;
    }
    

    Code Demo: http://jsfiddle.net/aASQe/

提交回复
热议问题