What is the best way to resolve the CSS border styling issue surrounding the anchor element?

I created a simple sign-up form for my school project where users can choose their roles. I'm facing an issue with the border under the anchor tag and I need help fixing it. How can I ensure that the space at the top is equal to the bottom as well?

Take a look at the image here

body {
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

.center {
  position: absolute;
  top: 150px;
  width: 99%;
  text-align: center;
  font-size: 18px;
}

.box {
  margin: auto;
  border: 1px solid #ccc;
  width: 30%;
  padding: 15px;
}

a {
  background-color: #333;
  text-decoration: none;
  display: block inline;
  color: white;
  padding: 14px 20px;
  margin: 8px 0px;
  border: none;
  cursor: pointer;
  width: 100%;
  opacity: 1.5;
}

a:hover {
  background-color: #ddd;
  color: black;
}

ul {
  list-style-type: none;
}

li {
  display: inline;
}
<div class="center">
  <div class="header">
    <h2>WELCOME TO SMK USJ 12<br/> ENGLISH QUIZ</h2>
  </div>
  <form action="role.php" method="post">
    <div class="box">
      <h3>Choose your role<br/> You are a...</h3>
      <a href="teacher.php">Teacher</a></button>
      <a href="student.php">Student</a>
    </div>
</div>

Answer №1

It appears there is a typo in the display property for the a tags. It seems like you intended to use inline-block instead of block inline, correct?

a {
  /* ... */
  display: inline-block;
  /* ... */
}

Answer №2

To improve the appearance of your buttons, one possible solution could involve making adjustments to your markup by adding a wrapping container for the buttons and styling that container accordingly. Alternatively, if you prefer not to modify your markup, you can still reach your desired outcome by incorporating some line-height properties into your button styles. For example:

.box a{
 line-height: 5em;
}

Implementing this CSS rule should bring you closer to achieving your goal.

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

Mixing together an array of colors, experimenting with adding a touch of transparency

Here is my first question, diving right in. I recently created a canvas in HTML and followed a tutorial to generate random floating circles that interact with the mouse position......if you want to check it out, click here. The issue I'm facing now ...

Code snippet for calculating the size of an HTML page using JavaScript/jQuery

Does anyone know of a way to calculate and display the size/weight (in KB) of an HTML page, similar to what is done here: Page size: 403.86KB This would include all resources such as text, images, and scripts. I came across a Pelican plugin that does th ...

What causes a div to shift to the right when the margin-left is set to auto?

I am curious to understand why setting the margin-left of the div with id="pink" to auto causes the div to move to the right side. Take a look at the image below: HTML <div id="aqua">aqua</div> <div id="yellow">yellow</div> & ...

Using importXML with Internet Explorer 11

My project website includes a roster page that retrieves XML data. Previously, this functionality worked across all browsers but now it only works in Chrome. In IE11, it seems that the importXML function is not functioning correctly as the roster data is m ...

How can I integrate material-ui with react-jsonschema-form?

Currently, I am working on a form utilizing react-jsonschema-form. However, I would like to further enhance the appearance of my application (including the form) by incorporating Material-UI. I am encountering difficulties integrating both frameworks toget ...

What is the reason for CSS to be included in the installation process when running npm install with [someLibraryName

After executing the following command: npm install vue-material I noticed that it installed and replaced some of the css styles in my application, leading to conflicts. To resolve this issue, I had to manually search for the specific piece of css and ove ...

Adjustable width columns in Flexbox design

I need assistance with creating a responsive three-column grid layout using Flex in CSS. I have achieved a fairly responsive design by following the CSS provided in the fiddle link below. However, I am facing an issue where the second column (the blue one) ...

Unable to close Bootstrap sidebar menu on mobile devices

I implemented a sidebar menu for mobile that opens when you click on the hamburger icon, with a dark overlay covering the body. The issue I encountered is that on mobile devices, the visibility of the menu does not change when clicked outside of it. It wor ...

Avoid auto-scaling of div content

I need the .content within the main container .box to resize proportionally to match the width of the .box exactly, without being smaller. .box { width: 95%; background-color: red; padding: 20px; text-align: center; margin: 55px auto 40px; } . ...

Incorporating visuals into Doxygen documentation

Struggling to add an image with a caption in a doxygen .md file. Adding a caption is easy, but aligning the image left is proving difficult. I've tried several methods, but none have worked successfully. ![Caption](my_image.png "Caption") R ...

What methods can be used to modify the appearance of the cursor depending on its position?

Is there a way to change the cursor to a left arrow when on the left half of the screen and switch it to a right arrow when on the right half, using JavaScript? I am trying to achieve something similar to what is shown on this website. I attempted to acco ...

What's the best way to modify HTML element classes using Javascript?

I have designed a custom cms theme with various customization options that I wish to showcase in a live demo. My goal is to implement Javascript style switchers or modifiers where users can choose values from checkboxes or select tags, and see their select ...

Tips for securely transmitting data via a hidden form using the POST method

I have a query that displays records of people, and I want to send the id_Persona using a hidden form through a post function to the idsPersonas.php page. However, when I try to do this, it redirects me to an undefined page. Here is the code snippet: < ...

One of my AngularJS directives seems to be malfunctioning while the rest are working fine. Can you help me troubleshoot

Recently, I've been immersing myself in the job search process and decided to create a website as a sort of online resume while also learning AngularJS. I enrolled in the Angular course on CodeSchool and am slowly building my website to my liking. (Pl ...

What is the best way to conduct automated tests on CSS rendering across various browsers, including Safari Mobile and the Android Browser?

Is there a way to programmatically and automatically test how CSS is rendered in various browsers, similar to how Selenium tests HTML and Javascript across different browsers? It would be great to integrate this with a BDD framework. ...

Is there a way to manipulate a website's HTML on my local machine using code?

I am currently working on a project to create a program that can scan through a website and censor inappropriate language. While I have been able to manually edit the text using Chrome Dev tools, I am unsure of how to automate this process with code. I ha ...

What is preventing my JQuery .animate() function from functioning properly?

<head> <script type="text/javascript" src="lib/jquery-1.9.0.min.js"></script> <script type="text/javascript" src="source/jquery.fancybox.js?v=2.1.4"></script> <link rel="stylesheet" type="text/css" href="source/jque ...

Showing child elements within a div using AngularJS

I am eager to create a straightforward AngularJS website that will showcase an initially hidden HTML element along with all of its children. Below is the HTML structure snippet I plan to use: <div class="hiddenStuff"> <h3>Game Over</h3&g ...

Title menu that can be both dragged and edited

I am currently working on developing an HTML user interface that enables my users to rearrange or organize the menu items or utilities according to their preference, much like the HOME screens on Android or iOS devices. I am seeking advice on how I can s ...

In Chrome, the "div" with the style attribute "resize:both" is unable to shrink, while it functions properly in Firefox

Here's the div code I'm working with: <div style='overflow:hidden;resize:both;border:1px solid orange;'> <div style='background-color:#aaa;width:400px;height:300px;'> </div> </div> You can view i ...