On a webpage, I have markup like the following:
<h3>Title Goes here</h3>
<a href="...">Link goes here</a>
<h3>Next title</h3>
<a href="...">Next link</a>
Some of these links have very long text and span multiple lines. I would like the following to occur:
- There is spacing between the first heading's link and the second heading.
- Links that span multiple lines have all lines but the first indented.
The way that this is accomplished currently is through the following CSS:
h2 + a, h3 + a, h4 + a, h5 + a, h6 + a {
margin: 0px 30px 20px 5px;
line-height:1.4;
display: inline-block;
padding-left: 10px;
text-indent: -10px;
}
The problem comes in because our links have the following formatting:
a {
color: #900;
text-decoration: none;
border-bottom: 1px dotted #333;
}
a:hover {
border-bottom: 1px solid #900;
}
Since the links under the headings have display: inline-block
, the border-bottom does not go under the text of each line, but rather under the whole box that the link generates. I'm not sure if there is way to get what I want here, since display:inline-block
seems necessary to get the margins and indenting that I want, but the border-bottom would only work with an inline element.
Is there a way to have my cake and underline it too, without altering the markup (eg wrapping the <a>
elements with <p>
)?