Putting the `href` attribute around an `input` of

Why is the

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org    /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen">
</head>
<body>
<a href="1.html"><input type="submit" class="button_active" value="1"></a>
<a href="2.html"><input type="submit" class="button" value="2"></a>
<a href="3.html"><input type="submit" class="button" value="3"></a>
</body>
</html>

style.css:

* {
    margin: 0;
    padding: 0;
}

/* CSS Buttons: http://www.web4site.de/css/css-buttons.php */
.button {
    padding:0;
    margin:0;
    border:none;
    font-size:14px;
    background: url(../img/button.gif) no-repeat center;
    color: #000000;
    height:27px;
    width:134px; 
    font-variant:small-caps;
}

.button:hover {
    padding:0;
    margin:0;
    border:none;
    font-size:14px;
    background: url(../img/button.gif) no-repeat center;
    color: #FF0000;
    height:27px;
    width:134px; 
    text-decoration:none;
    font-variant:small-caps;
}

.button_active {
    padding:0;
    margin:0;
    border:none;
    font-size:14px;
    background: url(../img/button.gif) no-repeat center;
    color: #FF0000;
    height:27px;
    width:134px; 
    font-variant:small-caps;
}

This setup functions correctly in Firefox...

Answer №1

What is the purpose of placing a submit button within an anchor element? Are you intending to submit a form or navigate to a different webpage? Please clarify.

If you want to submit the form, use the following code:

<input type="submit" class="btn_submit" value="Submit" />

If your goal is to redirect to another page, utilize this code:

<input type="button" class="btn_redirect" onclick="location.href='page2.html';" />

Answer №2

The reason it is not functioning properly is due to its lack of logical flow (to the point where HTML 5 clearly prohibits it).

In order to rectify this issue, determine whether you require a hyperlink or a submit button and implement your preferred choice (Tip: Without a form present, a submit button serves no purpose).

Answer №3

<a href="4.html"><input type="text" class="button_active" value="4"></a>
<a href="5.html"><input type="text" class="button" value="5"></a>
<a href="6.html"><input type="text" class="button" value="6"></a>

Give it a shot. Unless you absolutely must stick with the submit type, then the solution I presented should suffice. If you insist on using submit, then all the details mentioned earlier are valid, otherwise, it's nonsensical.

Answer №4

To correctly place the link location, simply insert it within the action="" attribute of a surrounding form element.

An example of your first link can be seen below:

<form action="example.html">
    <input type="submit" class="button_active" value="Click Here">
</form>

Answer №5

I completely agree with Quentin's point of view. It seems irrational to proceed in that manner. This is fundamental in the realm of the Semantic Web ideology. It is imperative to strategize and lay out the elements of your website to accommodate future integration and expansion possibilities. Without abiding by the correct use-case, other web applications or websites will not be able to interact with your content effectively.

Internet Explorer and Firefox operate differently. IE often allows features that are rejected by Firefox and other browsers that adhere to standardized practices.

If your intention is to design buttons without triggering data submission, consider utilizing a combination of DIV elements and CSS styling.

Answer №6

Completing this task is entirely possible. Simply ensure that the input type submit resides within a form element. Specify the desired redirection link by placing it in the action attribute within the form tag.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Attempting to implement a functionality that will allow users to easily delete records from the database

I've taken on a school project where I am tasked with creating a login/registration form. Additionally, I need to develop functionality that allows users to register, login, view records, and delete records from the database using a dropdown menu and ...

How can CSS be instructed to "apply the following most specific rule in order to determine this property"?

Utilizing Material-UI and JSS for CSS management, I've encountered an issue where styles appear differently in development versus production. The discrepancy stems from the order of rules within the file. For instance, when defining an element like ...

Your browser's popup blocker is preventing the file from being downloaded

I am encountering an issue with my PHP file download function where the browser's popup blocker is preventing the file from opening. My objective is to create an HTML form submit button that will send a form, modify an RTF file on the server based on ...

difficulties switching content between different screen sizes

Having trouble with hidden-xs and visible-xs-* classes not working as expected. Even a simple code snippet like the following doesn't hide the content: <div class="hidden-xs"> test test test </div> Even when scaling down my window to ...

Is it possible to change a Material UI style without resorting to an HOC?

Is there any method to modify the styling of a Material UI component without the need to create an entirely new component using withStyles()? For example, if I am currently displaying the following and simply want to adjust the color of the "Delete" label ...

Creating responsive lines with CSS on top of an image

I would like to add lines on an image using CSS3 and HTML5 Canvas. I came across a tutorial and demo that utilizes an html div: However, when attempting this effect on an image, the line appears outside of the image. How can I ensure that the line is dra ...

javascript display hide choose among

I am attempting to display another set of options when the user selects a specific item. For example, if the user selects "Products," then a new selection box should appear with different product types. See my code below: <html> <head> <m ...

What is the best way to limit the range slider before it reaches its maximum point?

I am currently utilizing angularjs to stop a range slider at 75%, however, the method I am using is not very efficient and is not working as desired. Is there anyone who can provide guidance on how to achieve this? Please note: I want to display a total ...

An issue occurred during the compilation of an Angular6 project

I am embarking on my first Angular project and may not grasp every detail perfectly. In my search for guidance, I came across the command "ng build --prod" on Google and decided to give it a try. Everything seemed to be going smoothly at first until an err ...

Locating content inside a span element with tags and spacing in jquery

Within the span class of teamName, there are various tags including white-spacing, a sup tag, and a p tag: <span class="teamName"> Dr.<sup>J</sup> W Smith ...

unable to pass the form data using the post method

A numerical value is entered by the user into a form, and based on a certain condition applied to that number, a list of addresses is displayed. My goal is to save the data that is retrieved through AJAX. Here is the code snippet from the page containing t ...

Expanding containers with flexbox to allow for flexibility in size

I need help with a page that contains 3 div elements, where 2 of them need to be resizable. These elements should be able to be moved left or right, and maximized or minimized. You can view the example on Stackblitz. The issue I'm facing is that som ...

What is the best way to line up several elements in a single column?

I am facing a layout challenge with two objects inside a column - a paragraph and an image. I need the image to be positioned at the bottom and the paragraph at the top. I have tried using various Bootstrap classes like "align-items-between" and "align-sel ...

JQuery's accordion with the heightStyle set to "fill" is causing a vertical scrollbar

I recently integrated the JQuery accordion effect into my website and specified the heightStyle: fill so that it would occupy the entire window. However, it seems to be taking up an additional 1 or 2 pixels, causing the vertical scroll bar to appear. I su ...

Utilize CSS Animation to bring overlapped images to life

Trying to replicate the animation featured on the CISO website header. I have created a JSFiddle demo showcasing my attempt, but it seems like something is not quite right. img { transition: all .3s ease; overflow: hidden ...

Issue encountered when attempting to connect an external script to a Vue single file component

Struggling to link an external script to a single file component in Vue. My project setup is as follows: https://i.sstatic.net/LWvNx.png I need to link the file components/Sshy to ../javascripts/ I have successfully linked other scripts using either of ...

Photo Collection: Incorporating Images

I am currently working on a project to create a photo gallery and I am facing an issue with adding photos. The user should be able to browse for a picture and enter a title for it on a page. Both the image path and title need to be saved in an XML file fro ...

Tips for adjusting the "active" navigation class across various pages using base.html

I have my main navigation bar located in the base.html file and I include it in all other pages. However, I currently have the class "active" assigned to the home page link, causing it to remain active on all other pages as well. <ul class="navbar-nav" ...

Angular element fails to display properly

I'm currently working on developing a website using Angular and creating a header component. To generate the necessary files, I used the command ng g c commons/header which creates the HTML, SCSS, TS, and .spec.ts files. I then made modifications to t ...

How can you assign a strokeStyle color to a Canvas using a CSS property?

Our team is currently working on an Angular2 / Ionic 2 project where we have implemented a HTML Canvas element that allows users to draw on it. One challenge we are facing is how to set the Canvas strokeStyle property using a color provided by a CSS style. ...