Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking to have a <hr> and <h3> together

Tags:

html

css

enter image description here

Like the example above. I've found some helpful script with the a small img which I do like however I don't know how to get the padding about the title so the line doesn't go straight through.

h3.line {
    background-attachment: scroll;
    background-clip: border-box;
    background-color: transparent;
    background-image: url(../images/line.jpg);
    background-origin: padding-box;
    background-position: center;
    background-repeat: repeat-x;
    background-size: auto auto;
    display: block;
    margin-bottom: 20px;
}

Which shows this. enter image description here

Any suggestion or ideas?

like image 590
kia4567 Avatar asked Feb 01 '12 20:02

kia4567


People also ask

What is h3 HTML?

The H3 element defines a level-three heading. This heading is more important than an H4 but less important than an H2. The deprecated ALIGN attribute suggests the horizontal alignment for the heading on visual browsers. Possible values are left, right, center, and justify.

How do you center a h3 tag in HTML?

To center, align all objects with the <h3> tag applied, redefining it with styles, and then select the Block category. Select Center from the Text Align drop-down menu, as shown in Figure 15.6, and click the OK button. Immediately after you click OK, the h3 text in your Web page should jump to center alignment.


2 Answers

You can have a 1px dot image which you can place as a background on the H3. Then have a span element in between which have a background on.

CSS:

h3 {
    background: url(images/dot.png) left center repeat-x;
    padding: 10px;
    text-align: center;
}
h3 span { background: #fff; display: inline-block; padding: 10px 15px; }

HTML:

<h3><span>About</span></h3>
like image 111
janhartmann Avatar answered Sep 19 '22 17:09

janhartmann


You can put a <span> for example in your <h3> and make it have the same background as your <h3> but without the line so the <span> effectively overlaps the <h3>.

You can say this to your span:

span {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

to make it center. You can add width and height to it too. line-height helps place your text to the middle vertically.

If you want to spare images than you can use text-decoration: line-through; to draw a line through your text.

like image 41
Adam Arold Avatar answered Sep 20 '22 17:09

Adam Arold