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:

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:

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

Does the zoom value in the HTML file adjust when I zoom in or out on the Google Map?

I'm uncertain if my question is sufficiently clear. Here's my dilemma: I've been utilizing the gmplot module in Python and I'm interested in adjusting the grids to be scalable based on the zoom level of the Google Map. However, being u ...

What is the best way to incorporate a range of details into a div using only jQuery, all while avoiding the use of data-

I'm struggling to find a concise way to explain this, so please bear with me. The information I'm sharing here is all just for example purposes and may sound strange. I have been working on creating a character select page where clicking on a cha ...

The CSS JSON code I have written is not having any impact on the appearance of my div

<!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="styles/common.css"> <script src="http://code.jquery.com/jquery-latest.min.js"></script> <script type='text/javascript'> ...

Modifying the Inactive Tab Color in Material UI

For my application, I have a specific requirement where the active tab needs to be styled in red and the inactive tab in blue. Here is how the styling is set up: newStyle: { backgroundColor: 'red', '&$selected': { b ...

Ways to position Drop-down menu flush against the left edge of the webpage?

I am facing a challenge in customizing my CSS3 Mega drop-down menu. I want the mega menu to start from the left side of the main page, beginning from the home button area and extending all the way to the end. Currently, it is appearing where the parent men ...

"Troubleshooting a JSON structure containing a complex array of objects with multiple layers

I've structured a complex array with JSON objects to allow users to customize background images and create unique characters. Below is the main code snippet: var newHead; var newBody; var newArm; var masterList = [ { {"creatureName":"Snowman ...

Tips for seamlessly placing a div with a background image within a parent container, all while preventing any scrolling issues as the child div rotates

I created a simple demo featuring a square image with rounded corners to give it a circular appearance. The image rotates slowly, but as it moves diagonally, the horizontal width fluctuates, causing the parent container to resize. I want the parent contain ...

How to position child divs at the center of a parent div

I am looking to set the maximum width of the "circlecontainer" to 300px, but I also want my 4 child divs (each with a max width of 300px) to remain centered in the browser when it exceeds a width of 1200px. Currently, they are aligned to the left side. Be ...

Troubleshooting the Issue: Iscroll.js Child Element Overflow Scroll Problem on iOS Devices

In my current project, I'm utilizing Iscroll.js to create a design where all elements must adjust to the height of the screen with a significant horizontal scroll. However, I've encountered an issue with certain elements overflowing vertically ba ...

The scrollable dialogue disrupts the background's ability to flex and grow

My page layout is pretty simple: <main> <header>Header</header> <section>Content</section> <footer>Footer</footer> </main> <dialog>Dialog</dialog> In terms of CSS, here's how it ...

Is there a way to adjust the text color of a label for a disabled input HTML element?

If the custom-switch is active: the label text color will be green. If the custom-switch is inactive: the label text color will be red. A JavaScript (JQuery) method call can be used to activate one button while deactivating another. The Issue It appe ...

Discovering the exact distance between a 'li' and a 'div' element

Currently, I am in the process of converting HTML to JSON. Here is an example of the HTML I am working with: <div class="treeprofit" id="divTreeViewIncomeDetails" style="height: auto;"> <li><span class="fa fa-folder-open highlight" ...

Display current weather conditions with the Open Weather API (featuring weather icons)

Hello everyone, I need some help from the community. I am currently working on a weather app using the openweather API. However, I'm facing an issue with displaying the weather conditions icon for each city. I have stored every icon id in a new array ...

Credit for the Position swipejs

After integrating a swipeJS photo slideshow into my jQuery mobile application, I encountered an issue. I am trying to create points for counting the pictures similar to what is seen on this page: Although I have added the necessary HTML and CSS code to my ...

Issue with display of Favicon in Google Chrome browser

My favicon is not appearing on my Chrome tab, even though I've checked multiple articles and confirmed that the code is correct. It does show up in Firefox, so I'm confused as to why it's not working in Chrome. I've cleared my cache and ...

Instructions on triggering a pop-up modal from a separate HTML document to the index page

I am trying to open a form in a Modal using a button. However, the Modal is located in a separate .html file. How can I use JavaScript to call the form from that external html file into my index.html file? Currently, I am able to call the Modal within the ...

Can JQuery's 'unslider' be customized to only change the backgrounds?

Check out my source at this link: http://codepen.io/anon/pen/Bvkjx Observe how the content and background images rotate correctly. Now, I'm curious if it's feasible to keep the following content static <p>SOME CONTENT1</p> while ...

Generate a new object from the contents of a div

Having the HTML structure below: <div id="main"> <div id="myDiv1"> <ul> <li>Abc</li> <li>Def</li> </ul> </div> <div id="myDiv2"> <ul> <li>Ghi</l ...

What is the best way to display and conceal elements depending on the chosen option using jQuery?

Can you help me figure out why this code isn't working as expected? <Script> $('#colorselector').change(function() { $('.colors').hide(); $('#' + $(this).val()).show(); }); </Script> < ...

Transform an xlsx document into a HTML file using VBscript or batch script

After extensive research, I have come up empty-handed in finding a solution to the issue I am facing. The problem at hand is that I have an Excel file in .xlsx format that needs to be converted to .html on a regular basis throughout the day. Once converte ...