How to set a border around a head 1 section?

I want css style can set a border around my head 1 section.

For example, I have a text with this content:

--- border 1----
|# head 1       |
|## A           |
|## B           |
|### B1         |
|### B2         |
|## C           |
|### c1         |
| some text |
- border 1 end --

--- border 2----
|# head 2       |
|## A           |
|## B           |
|### B1         |
- border 2 end --

How to make the css style like this?