When a Grid Item is enclosed in a link, it does not extend over rows

After avoiding HTML/CSS for a long time, I finally decided to dive in and create a simple CSS grid website with 3 items in the grid. Everything was working well and looking exactly as I wanted it to:

https://i.sstatic.net/zVQ9U.jpg

However, I had the idea of using the entire Aside-Items section as a hyperlink. So, I wrapped a href= around it, but then the same CSS ended up looking like this:

https://i.sstatic.net/jluUP.jpg

My questions are:

  1. How can I achieve the look from the first picture while making the "Aside-GridItem" function as a hyperlink?
  2. Is this approach acceptable, or will I face SEO issues by "hiding" the link with text-decoration: none?

Here is my code snippet:

.gridwrapper{
  display:grid;
  
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 3fr;
  grid-column-gap: 1px;
  background-color: wheat;
  gap: 5px;
}

.gridHeader{
  background-color:blueviolet;
  font-family: Helvetica, sans-serif;
  font-size: 32px;
  padding: 1em;

  grid-row: 1 / 2;
  grid-column: 1 / 2;
}

.gridContent{
  background-color:blue;
  font-family: Helvetica, sans-serif;
  font-size: 32px;
  padding: 1em;

  grid-row: 2 / 3;
  grid-column: 1 / 2;
}

.gridAside{
  background-color:goldenrod;
  font-family: Helvetica, sans-serif;
  font-size: 32px;
  padding: 1em;

  grid-row: 1 / 3;
  grid-column: 2 / 3;
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="main.css">
  <title>BlazorFK</title>
</head>
<body>

<div class="gridwrapper">
  <div class="gridHeader">HEADER</div>
  <div class="gridContent">...content...</div>
  <a href="https://google.com" style="text-decoration: none;">
    <div class="gridAside">Aside</div>
  </a>
</div>
</body>
<script></script>
</html>

Answer №1

relocate the class="gridAside" from the <a> tag to its parent link like this:

<a class="gridAside" href="https://google.com" style="text-decoration: none;">

Sample

.gridwrapper {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 3fr;
  grid-column-gap: 1px;
  background-color: wheat;
  gap: 5px;
}

.gridHeader {
  background-color: blueviolet;
  font-family: Helvetica, sans-serif;
  font-size: 32px;
  padding: 1em;
  grid-row: 1 / 2;
  grid-column: 1 / 2;
}

.gridContent {
  background-color: blue;
  font-family: Helvetica, sans-serif;
  font-size: 32px;
  padding: 1em;
  grid-row: 2 / 3;
  grid-column: 1 / 2;
}

.gridAside {
  background-color: goldenrod;
  font-family: Helvetica, sans-serif;
  font-size: 32px;
  padding: 1em;
  grid-row: 1 / 3;
  grid-column: 2 / 3;
}
<!DOCTYPE html>
<html lang="en">
<head>
  <title>BlazorFK</title>
</head>
<body>
  <div class="gridwrapper">
    <div class="gridHeader">HEADER</div>
    <div class="gridContent">...content...</div>
    <a class="gridAside" href="https://google.com" style="text-decoration: none;">
      <div>Aside</div>
    </a>
  </div>
</body>

</html>

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

Which option offers superior performance: using attributes through HTML or jQuery?

At times, I find myself needing to include special classes, divs, and attributes in my HTML code for jQuery scripts to function properly (the site's "no-JavaScript" version doesn't require these elements). You probably understand what I mean. I& ...

In relation to CSS and HTML

I recently started working on a website built with HTML/CSS and encountered an issue with links highlighting when hovered over. The problem arises from the main image on the homepage containing an embedded link, causing the area under it to also highlight ...

Flexbox Resizing Notification(?)

Recently, I've been utilizing flexbox in my layout design and it has been a game-changer. However, I am facing an issue that might be linked to my heavy use of AngularJS, particularly the ng-include feature. The specific problem arises when I incorpo ...

Ways to apply the margin-top property to create space between an input field and

I have been experimenting with Vue and I created a simple code snippet. <template> <div> <input /> <span class="span-text">Hi</span> </div> </template> // index.css .span{ margin-top: 3px; } I a ...

Increase the thickness of the scrollbar track over the scrollbar thumb

I've come across several discussions on making the track thinner than the scrollbar thumb, but I'm looking to do the opposite. Is it possible to have a scrollbar track that is thicker than the scrollbar thumb? ...

Tips for aligning one item in the center and another item on the right with MUI v5

My goal is to center 3 navigation tabs in the middle of my page and have a dropdown on the far right for sorting. I managed to get the dropdown on the far right, but I'm having trouble perfectly centering the 3 navigation tabs inside the <Box> & ...

Can the arrangement of icons/buttons on the JW Player control bar be customized?

I am trying to customize the skin of my JWplayer like this: This is my current progress: I have been researching how to rearrange the order of icon / button on the controlbar. According to the jwplayer documentation, the buttons on the controlbar are div ...

Issues with zoom functionality not functioning properly within IE11

I am currently developing an application with Angular that is designed to be compatible with tablets and touch-enabled devices. One of the key features I want to implement is the ability for users to zoom/scale up the app, especially for those with visual ...

Responsive on Mobile Devices

I'm seeking assistance in brainstorming a creative idea or method to convert the carousel indicators into a menu, or any alternative approach to ensure the entire section is mobile responsive while keeping all the indicators visible within the mobile ...

Generate a table framework by dynamically adjusting the number of rows and columns

I'm running into an issue with my implementation of nested for-loops to dynamically generate a table using JavaScript. For this particular scenario, let's assume numRows = 2 and numCols = 6. This is the code snippet in question: let table = $( ...

The "maxlength" attribute does not function with the input type "number" in an HTML textbox

The maxlength attribute does not seem to be functioning properly when using type="number" ...

Transitioning between modals using Tabler/Bootstrap components in a ReactJS environment

Currently, I am constructing a Tabler dashboard and incorporating some ReactJS components into it. Initially, I used traditional HTML pages along with Jinja2 templates. However, I have now started integrating ReactJS for certain components. I prefer not t ...

conceal the mustard-colored dots within the overlay

Whenever I trigger the link, a modal window pops up, but it comes with an unwanted black background color and yellow dots. How can I prevent the yellow dots from showing up on the overlay? http://jsfiddle.net/y88WX/18/embedded/result/ <nav class="da-d ...

What are some ways to enable text highlighting when it is disabled?

I've encountered an issue with text highlighting in my asp.net web application when using the latest versions of FireFox and Google Chrome. Strangely, pressing CTRL+A also does not work for all input fields. I haven't had the opportunity to test ...

Add the number provided in the input to the href

I'm attempting to add a number from an input field to the URL in a link. Currently, my code is replacing the entire URL instead of simply adding to the end of it: <input id='customquantity' type='number'></input> < ...

Toggle the visibility of images with input radio buttons

Explanation I am attempting to display an image and hide the others based on a radio input selection. It works without using label, but when I add label, it does not work properly. The issue may be with eq($(this).index()) as it ends up selecting a differ ...

Background color applied to row elements in div containers

I've been experimenting with integrating table content into CSS floats, but I'm facing some challenges. My current strategy involves using divs at the "table," "row," and "cell" levels. However, I'm not convinced that this is the most effec ...

Tips for maintaining the height of the outer div consistent with that of the inner div

I am encountering an issue with an inner div that is used for overlay and set to a min-height property. Despite changes in the overlay's height, the height of the outer div remains unaffected. #outer { width: 70px; height: 70px; background-co ...

Troubleshooting Problem with Centering Rows in Bootstrap

I am utilizing the most recent version of Bootstrap 3 to design a website for a friend, but I am encountering a challenge with centering elements on the page. Typically, I would use the following code: .center{ width: 90%; margin: 0 auto; } Howev ...

Looking to fetch the title, description, and uploaded image all in one row and showcase them using PHP

My contact-form-submission.php file is responsible for inserting form data into a Database and uploading logos to the uploads folder. Here's a snippet of the code: <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($ ...