How to make my click accessible through keyboard tab [duplicate] - html

This question already has answers here:
How do I make links with no href attribute accessible?
(2 answers)
Closed 5 years ago.
I have this link that looks more like a button - but whenever I am testing my tab navigation via keyboard - this link is never it and the user can't use it.
How can I make it ADA compliant and use aria to make it accessible via keyboard?
<div class="styles">
<a class="btn btn-primary" (click)="handlingClick($event)" id="addUser">Add User</a>
</div>

You have to add the tabindex attribute.
<a class="btn btn-primary" (click)="handlingClick($event)" id="addUser" tabindex="0">Add User</a>
The value 0 gives it a natural tab index based on the order of the DOM elements.
Here is some additional documentation.

Anchor elements are natively focusable. The reason that your link does not receive focus is because it doesn't have an href attribute.
Another way of approaching this problem would be to add a non-existent URL fragment identifier to the href attribute, like this:
<div class="styles">
<a class="btn btn-primary" href="#void" (click)="handlingClick($event)" id="addUser">Add User</a>
</div>

Related

My button that takes to a link does not work [duplicate]

This question already has answers here:
How do I create an HTML button that acts like a link?
(35 answers)
Closed 1 year ago.
I was making my HTML and suddenly my button wouldn't work
<button class="button.hover:links" formaction="Link here">Next</button>
So how to make it work because ever since yesterday it wouldn't work
First I am not sure why you chose the formaction attribute as the destination URL to link there.
The button with the formaction attribute should be working inside <form> tag.
The formaction attribute specifies where to send the form-data when a form is submitted.
The formaction attribute is only used for buttons with type="submit".
If you want a button which link to a URL you should make a button inside the <a> tag.
<a href="your URL"> <button class="your class">HTML here</button> </>
Second, it doesn’t make sense you put a class name as a CSS recognizable string.
You should define CSS independently and import that to use. Or you can use style attribute to set inline CSS.
import "index.css"
<button class="myclass">
...
File index.css
button.myclass:hover{
// Your style
}
If you want to link something to a button, you can do something like this:
<a href="INSERT LINK HERE">
<button class="button.hover:links" formaction="HTML here">Next</button>
</a>

How can I make a button redirect you in HTML? [duplicate]

This question already has answers here:
How do I create an HTML button that acts like a link?
(35 answers)
Closed 2 years ago.
I have been curious about the <button> attribute. I can't seem to get it to work like <a> attributes. What do I mean by that? Well, I can do Link to redirect you. But you can't do that with <button>. How can I make a button do the same?
Do you mean like this?
<button onclick="location.href='http://www.google.com/';">Go There!</button>
Well you can attach a button to a form and have it submit it which will load the page.
<form id="xxx" action="https://www.stackoverflow.com"></form>
<button form="xxx">Go now!</button>
You can try setting the <a> inside the <button> like this
<button>
Salir
</button>

Browser ignores download attribute [duplicate]

This question already has answers here:
Chrome 65 blocks cross-origin <a download>. Client-side workaround to force download?
(2 answers)
Closed 3 years ago.
I need help. My download button:
<button type="button" download="logo.svg" href="[SVG_URL]">Download SVG</button>
it is supposed to download an .svg file, but the download attribute is not working. It only opens the file in a new tab. It happens with firefox and chrome also.
Here's the problem live.
You need to use an anchor tag to make something downloadable.
Like
<a href="/images/myw3schoolsimage.jpg" download>Click to Download</a>
But in case you want a button with a downloadable link, here is it
<button><a href="/images/myw3schoolsimage.jpg" download>Chick Here</a></button>
Just put the anchor tag with an attribute "download" inside a button.
To read more about anchor tags w3schools
In your case, as I saw from your site, use the code snippet below
<a type="button" class="btn btn-primary" download="https://cdn.glitch.com/63be2122-7b8d-4d1e-85a5-7d557ae54cc5%2FUPS.svg?1555285173725" href="" target="_blank">Download SVG</a>
Here, instead of putting the URL in href we are giving it to the download attribute.

Link to form with Button selected as primary

I am trying to link to a page on a different site that contains three buttons in a form. When I link to the page xyz.com/form , by default the 'Highlighted' button is checked since it contains the btn-primary class. How can I create a link from my site linking to xyz.com/form with the btn-primary class selected for 'Link One' or 'Link Two' rather than 'Highlighted'?
<form>
<div class="col-xs-12">
<a class="btn btn-block btn-default btn-primary">Highlighted</a>
<a class="btn btn-block btn-default">Link One</a>
<a class="btn btn-block btn-default">Link Two</a>
</div>
</form>
You can't.
It isn't possible to make arbitrary changes to the HTML of an arbitrary site through the URL.
(If it was, you could watch as I linked to your bank's online banking service with a link that changed their login form to point to my own, malicious, site).
You would have to make the changes on the site hosting the HTML you want to change.
Ideally, you would create different pages representing each version of the page. You could do this dynamically using server-side code which (for instance) paid attention to the query string.
You could also use JavaScript (in the page) to examine the URL and modify the DOM based on it.

How do I link two HTML pages with a button? [duplicate]

This question already has answers here:
How do I create an HTML button that acts like a link?
(35 answers)
Closed 7 years ago.
I've got two HTML pages, with one being an opening page for an application and the second being a login page. I have a button on the opening page and I want to be able to click on it and have it take me to the login page. How do I do this?
This will add a button and link it to the login page:
<a href="path_to_login_page">
<button>Take me to the login page</button>
</a>
Change path_to_login_page & Take me to the login page to customize the button. If you already have a customized button and want to use it:
<a href="path_to_login_page">
'Place your button here'
</a>
Personally I would just change the button to a standard anchor. You could still style the link to make it look like a button.
Go home
If the element really must remain a button, you could do this:
<button onclick="location.href='index.html'>Go home</button>
It's not exactly best practice, though.
THIS IS THE SHORTEST AND THE FASTEST WAY TO DO IT:
<a href="login-page.html">
<button> Login Page</button>
</a>
Run and Check it here: https://jsfiddle.net/2zov6q2v/14/