Compose a duo of connected hyperlinks

 .btn {
                      box-shadow: none !important;
                      outline: 0;
                    }
    
                    .list-group-item span {
                      border: solid #222;
                      border-width: 0 1px 1px 0;
                      display: inline;
                      cursor: pointer;
                      padding: 3px;
                      position: absolute;
                      right: 0;
                      margin-top: 10px;
                    }
    
                    .list-group-item a.btn.collapsed span {
                      transform: rotate(40deg);
                      -webkit-transform: rotate(40deg);
                      transition: .3s transform ease-in-out;
                    }
    
                    .list-group-item a.btn span {
                      transform: rotate(-140deg);
                      -webkit-transform: rotate(-140deg);
                      transition: .3s transform ease-in-out;
                    }

<!DOCTYPE html>
    <html lang="en">
    
    <head>
      <meta charset="UTF-8">
      <title>Document</title>
    </head>
    
    <body>
    
      <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
    
      <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
    
      <div class="container">
        <div class="row">
          <div class="col">
            <div class="my-5">
              <ul class="list-group list-group-flush">
    
                <li class="list-group-item px-0">
                  <a class="btn collapsed" data-toggle="collapse" href="#collapseExample1" role="button" aria-expanded="true" aria-controls="collapseExample1">
                Link with href<span class="mr-3"></span>
                </a>
                  <div class="collapse" id="collapseExample1">
                    <div class="card card-body mt-2">
                      Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
                    </div>
                  </div>
                </li>
    
                <li class="list-group-item px-0">
                  <a class="btn collapsed" data-toggle="collapse" href="#collapseExample2" role="button" aria-expanded="true" aria-controls="collapseExample2">
                Link with href<span class="mr-3"></span>
                </a>
                  <div class="collapse" id="collapseExample2">
                    <div class="card card-body mt-2">
                      Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
                    </div>
                  </div>
                </li>
    
                <li class="list-group-item px-0">
                  <a class="btn collapsed" data-toggle="collapse" href="#collapseExample3" role="button" aria-expanded="true" aria-controls="collapseExample3">
                Link with href<span class="mr-3"></span>
                </a>
                  <div class="collapse" id="collapseExample3">
                    <div class="card card-body mt-2">
                      Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
                    </div>
                  </div>
                </li>
    
              </ul>
            </div>
          </div>
        </div>
      </div>
    
    
    </body>
    
    </html>

How can I add an extra link to another webpage within the text "Link with href?"

<li class="list-group-item px-0"> <a class="btn collapsed" data-toggle="collapse" href="#collapseExample3" role="button" aria-expanded="true" aria-controls="collapseExample3"> <a href="someURL">New Page Link</a> <span class="mr-3"></span> </a> 

This is not working as expected. I want to have the link in the "arrow" section of the li element to expand the corresponding div, while also having another link within the text "Link with href" that directs to a different page. The layout gets disrupted when trying to include two anchor tags inside the same li element.

Answer №1

Regrettably, nesting an anchor tag inside another anchor tag is not allowed in HTML5. Your intentions with the layout are not entirely clear. It might be beneficial to include mockups or wireframes for better understanding.

To demonstrate that it can be done, you can utilize positioning to create the impression of one anchor being nested within another. Below is an example:

CSS

li {
  position: relative;
  height: 70px;
  width: 300px;
  background-color: gray;
  list-style: none;
}
.big {
  display: flex;
  position: absolute;
  z-index: 1;
  color: white;
  height: 70px;
  width: 300px;
  background-color: blue;
}
.small {
  position: absolute;
  z-index: 2;
  bottom: 10px;
  height: 30px;
  background-color: white;
}

HTML

<li>
<a href="google.com" class="big">Big anchor</a>
<a href="facebook.com" class="small">Small anchor</a>
</li>

You can see a demo here: https://jsfiddle.net/j0eq6bxr/14/

If provided with visual examples of your objective, I may be able to offer a solution more aligned with your needs.

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

Using jQuery, adjust the width of child elements within a container by applying dynamic CSS styling

I am attempting to dynamically set the width of several child elements using jQuery. Here is what I am trying to achieve: Obtain the count of the desired containers (since there will be multiple instances of the .steps-container class in the DOM) Iterate ...

Tips for setting up date ranges in Fullcalendar

Currently, I am in the process of developing a fire department shift calendar using fullcalendar. I am faced with the task of altering the CSS for specific dates at irregular intervals that do not correspond to typical days of the week. In this particular ...

Transforming the sentence into a particular keyboard symbol

Looking for a way to transform this code snippet: <tr> <td width="100%" bgcolor="#96002D" height="3" style="font-size: 1px; line-height: 1px;">&nbsp;</td> </tr> From just a single line into a series of "/" characters like so ...

@media query not functioning properly on mobile devices

Attempting to develop a responsive email, I've included the following tag in my email template: <meta name="viewport" content="width=device-width, initial-scale=1.0"> In addition, I've implemented specific styling attributes for mobile de ...

"Customizing the gaps between cluster bars on AmCharts JS for a clean and professional

Previously, I utilized the AmCharts flash version where creating clustered column/bar charts like the image below was a breeze. In that setup, the clustered bars were tightly packed with no spacing in between. However, transitioning to the JS version of Am ...

Trouble with select box initialization resolved

I'm having trouble retrieving the selected value from a dropdown menu as it always returns the first value. Initially, the dropdown is empty. When I press a button to open the modal and populate the dropdown with options, it seems that the issue aris ...

Adaptive text sizing within Microsoft Outlook

I am facing a challenge in making the font size of my email signature responsive. Although VW seems to be the solution, it doesn't seem to work in Outlook. I have attempted using CSS, but it appears that inline CSS might be necessary. However, I am un ...

Challenges with Media Queries post Integration of MUI Library in React

I have been scratching my head for the last few hours. I needed to utilize a react library to design my dog app for a project. Opting for the MUI library, it has been effective for the grid layout. However, the challenge arises when attempting to implement ...

Aligning HTML form with CSS styling

After researching various strategies on how to achieve this, and implementing the suggestions provided, I am still encountering difficulties. While the text successfully centers, the actual elements remain aligned to the left of the screen. Below is the f ...

Maintaining the active status of section 1 after the page is refreshed using Javascript and CSS

I have a total of 3 buttons and 3 hidden sections available, which can be seen in the image below: click here for image description Whenever one of the buttons is clicked, the respective section transitions from being hidden to becoming visible: click he ...

Adding a new row to a Bootstrap table while maintaining the consistent style

Is there a way to dynamically add a new table row with different styling using jQuery? I'm facing this particular issue and need help in solving it. Below, I have included some screenshots of my code and the view for better understanding. Here is the ...

How can we stop the brief display of a hidden div from occurring?

I have two divs on my webpage - one to display if JavaScript is disabled, and another if JavaScript is enabled. The issue I am facing is that even when JavaScript is not disabled, the div containing the message stating that JavaScript is disabled briefly ...

Is there a method to view text options that are too long within a fixed width <select multiple> HTML box?

Here is the code I am working with: <div id='div2' style='height: 430px; width: 350px; overflow:auto;'> <select multiple id="id" size="28" style="FONT-SIZE: 12px; FONT-FAMILY: Arial; width: 100%"> It's a challenge bec ...

jmpress: Scrolling through Absolutely Positioned Element (Slide) with dynamic height

Check out the Live Site I'm currently working on a website using jmpress, but I'm facing difficulties in implementing scrolling functionality for my content. While I can scroll in Chrome by selecting text and dragging down, I want to achieve thi ...

Design a big-sized button using Bootstrap framework

Is there a way to design a big, responsive button using Bootstrap? Similar to the example image linked below https://i.sstatic.net/xEBwc.png ...

Prevent Scrollbars in a Div

At the bottom of my website, there is a carousel slider that moves left and right when I scroll over it. Is there a way to disable this movement? If anyone has any suggestions on how to disable this feature, I would greatly appreciate it. ...

Tips for designing an intricate Bootstrap 4 layout

I'm having trouble positioning box 7 below box 6, can someone help me with this? Here is the code for reference. To test it on your machine, make sure to include Bootstrap 4 from a CDN: https://www.w3schools.com/bootstrap4/bootstrap_get_started.asp ...

The color type input is not responding to the onChange event

I have been searching a lot and exploring answers on Stack Overflow, yet I have had no luck. I am trying to retrieve the color value when the color is changed in an input field. Here is the code I am using, could you please assist me in finding out why it ...

Unnecessary list elements generated by dazzling navbarPage

While developing an app with shiny using navbarPage, I noticed that there are some unwanted li tags in the HTML that are not defined in my code. Could this be a known bug? How can I go about fixing it? <nav class="navbar navbar-default navbar-stati ...

Strange spacing issues with inline-block elements and struggling to vertically center content within them

I feel like I'm losing my mind trying to figure this out... any help would be greatly appreciated. There are three divs on the page that need to sit on a single line. They must be square with rounded corners, so setting width and height is necessary ...