1- Does the <a> have to be an <a>. Unless you want to navigate to somewhere when the <a> is clicked, I would just make it a <div> instead and that solves your problem when the exposed checkbox is clicked.
2- you could probably ditch the <span> around the <label> and give the <label> the add-to-scrapbook class name.
The OP might have used an <a> so that, with CSS, it works with the keyboard too. That’s the only reason I use an anchor, otherwise JS would be required to work with keyboard
I use this CSS technique on help text in my forms. But if you are clicking on these things then you have an issue.
If you want the span to be visible on click, in all browsers, then as webdev1958 mentions you will need Javascript. Without Javascript, you can get the span to appear onscreen in everyone but Chrome and Safari on click, because when you click you leave the :focus on the anchor which shows the span along with :hover.
<a href=“#void”><span>here’s some text</span></a>
a {
position: relative;
}
a span {
position: absolute;
margin-left: -999em;
other styles here, like width etc;
}
I’ve got it to appear/disapear using CSS when you mouseover the <a href> but as the <a href> surrounds it, when I click on the checkbox it selects the <a href>…
I use Javascript to hide/show parts of forms, since yeah you do not want a form control inside an anchor like that. In the link above, an entire fieldset is brought onscreen if you choose “Ja” on the “Jongere bestuurder?” question.
The span class ‘add-to-scrapbook’ needs to be hidden but appear on mouseover.
I’ve got it to appear/disapear using CSS when you mouseover the <a href> but as the <a href> surrounds it, when I click on the checkbox it selects the <a href>…
…looking at the code anew I probably don’t even need a span ‘add-to-scrapbook’ - just style the label - but thats another issue.