I´m working on a site, which collects famous Quotes. The Text of the quote is a link to do something else [...] But I also wants, that the user can select and copy the text of the quote.
But in nearly every browser the user cannot easily select text in Links.
Is it possible to override this in CSS and make it possible to the user to select the text?
In Firefox, you can select parts of the hyperlinks by pressing the Alt key and then selecting as usual with the mouse. So one option is to implement something similar using jQuery: if the Alt key is pressed (or a key that you assign) and the mouse pointer is over the link, then disable the link. When the key is released then enable the link.
Of course you would have to tell your users how to make the selection.
You can,
Step 1 :
Create an attribute draggable to anchor tag.
<a href="http://www.exaple.com" **draggable="false"**>Select Text From Here</a>
Step 2 :
Make cursor style auto & user-select must be text or all
a
{
cursor: auto;
-webkit-user-select: text;
-moz-select: text;
-ms-select: text;
user-select: text;
}
This isn’t really a job for CSS, as this is functionality, not rendering. And it is a difficult issue, because a click on a link is supposed to mean following the link, and breaking this would create a major usability problem.
The best approach is to avoid making the quotations links and use links separately along with them. For example, the credits below a quotation, or the name of the cited resource in the credits, would be a natural link. And if you want a click to “do something else”, then perhaps you should use buttons, not links, associated with the quotations.
You can't. You can, however, make an element look like a link but use JS to actually handle the "link" part of it.
jQuery:
$(".q").click(function() {
window.location.href=$(this).attr('data-link');
});
HTML:
<span data-link="link.html" class="q">text here</span>
CSS (to give it the "hand" cursor)
.q {
cursor: pointer;
}
Demo
I would just keep the quote just text (no link) and then add a smaller link at the end for more info or whatever it may be.
No, but you shouldn't have massive blocks of text in a link - a link should ideally be just one or two words, not an entire paragraph.
I can't tell without seeing your site in action, but I suspect that the problem is that your link tag contains more than just the quote.
If the link shows as "To be or not to be--that is the question", then selecting it should be the same as selecting any other question. If the link is "Here's a great quote: 'To be or not to be--that is the question. Click here to do something else!" then they won't be able to select the text in the middle, which is all they're going to want.
Make sure that your link text is only the text that they want to select, and put anything else outside of the tags, and you'll be fine.
Say you had a "box" like call to action link, and the primary purpose and use for it is to bring the user to a new page. Equally important though, is a means to "select" some of that text (e.g. address, phone number, or in your case - lyrics) something as following works well.
The caveat being, the "selectable" text itself, is not clickable. But then again, for someone who has the intent of selecting the text that won't be a problem. For anyone else trying to hit that link, well, they'll have to click a tad beyond the selectable text boundaries.
<!-- See stylized version in CodePen link below -->
<div class="box-link">
<span>Apple Park Visitor Centre</span>
<span class="box-link__text">10600 North Tantau Avenue<br />Cupertino, CA 95014</span>
</div>
Link to CodePen:
https://codepen.io/mjoanisse/pen/YMNaae
Related
Is there a way to turn CSS elipsis dots into a link ?
Something like
text text text text... (The three dots should show up as a link). I read an answer and found that this was not doable. So I managed with substring Operation on paragraph and then wrapping '...' inside <a>tag. Thanks for all your asnwers
There is no way of turning the ellipsis dots into a link (if you are using the text-overflow styling).
However <a> (link) elements are inline elements - so will naturally follow on from whatever text you have... .so the simplest approach would be to append an <a> element to the end of the text... (note that I am using the html entity (…) of an ellipsis - rather than simply 3 dots....
However - this is not really advisable from an accessibility or user experience stand point.... an <a> element is used to take the user to another location - not really to act as a house for the ellipsis .... and here is nothibng to tell the user that there is a link there - nor what happens when you click it.
A Far better approach would be a dedicated and obvious link element - or a show more / show less button at the end of the text... and yes - I say a button...
A link should take the user to another location or context .. .and a button (which can be styled to look like a link) is used to alter the content or perform a function in the same location or context.
Using the right HTMLelement for the right job is important... and so is understanding the outcome of coding choices... you would need to have a good reason to make an ellipsis the link text - and not simply as a show-more... IMO
p, a {
color: #222;
}
a {
text-decoration: none;
}
<p>text text text text …</p>
Is there some ARIA or other way to mark a given HTML node so as to be skipped when the user searches for text on the page (Ctrl+F/Cmd+F)?
Use case: hiding accessible/fallback text from searches
Example: search on this page for the word down. You should only find the instance in the previous sentence, but Chrome will show as many search results as there are answers to this question, plus one, because the question itself, and each answer, have a "d... vote" a link text.
Such search results aren't highlighted, and it can appear frustrating to see "1 of X" in the search box, while there's nothing visible that matches what the user has searched for.
Not sure if I understood you correctly, but if you develop your own app, not hacking SO source, maybe using of CSS :before or :after pseudo-elements filled with content property will help.
For example, the text ”Hello“ is not found in Safari, Chrome and Firefox when added by the content property:
.text:before {
content: 'Hello';
}
Opera 12.x finds the word on the page, so if its support makes sense for you, this solution won't work. I also haven't test it in any version of IE, mobile browsers and other infrequent environments.
In the example you could remove the "down vote" text (replacing it with , whitespace, or empty string) because the a tag already contains a title attributes which aimed to be used by screen readers.
The fallback is then only necessary with a text browser like lynx, which will ignore CSS. So, you can use a markup like
<a href="#" title="Explicit alternative">
<span class="hidden">Explicit alternative</span>
</a>
Setting display:none on class hidden
If you doubt that your title attribute is enough, you could add an aria-label attribute, but it's not necessary.
I am not a HTML/CSS expert but I am in charge of developing and maintaining a website for my employer.
I have set of link in the middle of my webpage that I want to have a specific CSS applied to without affecting any of the other links, and really the only change I want to make is to move the title popup to the right. Basically, the pointing hand hover mouse icon blocks the text in the title, so I want to move the popup to the right of the pointer, so that it can be read completely during a hover.
I've seen a few different ways to manipulate the title popup but they are either way too complex for what I need, way too simple in that they affect all <a> tags on the page, or do not explain how to do what I want which is just move the popup to the right a little bit.
You can manually style any element of the page by using 'inline styling' which will not effect any of the other elements on the page.
You do this in the HTML rather than the Style sheet, for example say your style sheet has:
.tinybutton {margin:0;padding;0:}
Which would use the element in HTML as:
<a class="tinybutton" href="#"> </a>
Now let's pretend you want to move the button slightly right without editing the CSS you then use the inline styling like so:
<a class="tinybutton" style="margin-left:10px" href="#"> </a>
So in other words just add style=" " with the styling options you require to the element that you want to edit without effecting the CSS.
Now that you have answered your own question, I know that the titles you are trying to move are tool-tips generated by the browser.
Not only can those not be moved, these tooltips are browser dependent and looks different on each browser. I have no idea which one you are using but it is not Chrome because we made sure that the tooltip does not overlap the mouse cursor.
The other possibility, like the jQuery plugin you mentioned, is to write Javascript that renders each title in its own invisible HTML element. Then it makes those tooltips appear on by adding an a :hover style or mouse-event-handler.
Having done further research on this, I found several questions in StackExchange that indicate that a title cannot be modified. So given this:
<a title='stuff here' href='#'>Click me!</a>
it is not possible to manipulate the "stuff here" section using jscript, css, etc. The only option is to use a jQuery plugin or something along those lines, and that has proven to be beyond my ability to troubleshoot.
For the time being, I simply added spaces to the front of the title to push the text out, like this:
<a title=' stuff here' href='#'>Click me!</a>
Probably a silly questions, but I'd like to have a hyperlink withing another hyperlink, much like a
<a href="#somewhere">
This is the hyperlink,
and this is the other one
</a>
Aside from that it's not compliant and all, is there a way of doing this?
*Edit: the outer hyperlink is used by a carousel, and won't take the browser somewhere.
Lets think about this. What is the browser suppose to do?
Go to the first hyperlink, or the second one, or both?
If you want the first one, then the second hyperlink is not required.
If you want the second one, then close the first one before and reopen if necessary after closing the second.
If both then write some Javascript to get it to open a new window. for the second hyperlink before loading the first hyperlink.
Anchor tags, just like inline or block level elements, layer up on top of each other when nested such that attributes can be set for different subsets of information or visual space within them. This may be useful if you have a large anchor element functioning as a large button, but want to insert a link to a different location within that button.
Have you tried implementing it? See this jsFiddle proving that nested inline elements work, both with span and anchor tags. Note that the nested element overrides the clickable area subset within the parent element, just as you'd expect it to if you were listening for a hover event.
Disclaimer: While technically this can be done, that doesn't mean that it should be done. Nesting links in particular can result in user confusion and be misleading about what content is pointing to what locations.
You can't nest it, but you can do something I did below..
<a href="somewhere">
This is the hyperlink,</a>
and this is the other one
May be you solution:
<form action="http://myhomepage.ru/" method="get">
second link within
<button>first link</button>
</form>
I have some HTML DOM elements for which I need to capture click events, like a drop-down menu widget, etc.
I guess we can implement in 2 ways:
My text
or another way is:
<span id="option2">My text 2</span>
In the second option, of course I can add CSS property cursor:pointer.
All I need is to capture the click event, for which I can have the same click handler function for both the cases.
Do you think there is any reason why we would use anchor tag method?
The second option looks more clean. Also, the IE has a default behavior for anchor tag click events, which can have unwanted consequences, etc.
Some benefits of the anchor tag:
you can provide a default behavior for users who don't have JavaScript enabled (if you care about that).
tabbing on the keyboard will set focus on anchor tags by default.
you get default styles that may be desirable on anchor tags.
Depends on what you need/want. Using links have the benefit they will be displayed as links (other color, different mouse cursor, possibility to search only for links, maybe accessibility issues, etc.)
Using spans does not do this but has other benefits like no different color if you activated or visited the link already.
That being said there is IMHO no real benefit for choosing either method probably depends if the text should be displayed/behave like a link or not.
For span look like an anchor you have to setup colors (standard and hover. And there'is no way to set Visited for it), underline and cursor:pointer. Still think it's cleaner?