The Wayback Machine - https://web.archive.org/web/20241004223217/https://www.geeksforgeeks.org/bootstrap-5-stretched-link/
Open In App

Bootstrap 5 Stretched link

Last Updated : 29 Dec, 2022
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Bootstrap 5 Stretched link is used to make any component clickable. Multiple links are not recommended. The card in bootstrap has position:relative by default, so we can easily add .stretched-link class to a link.

Bootstrap 5 Stretched link class:

  • stretched-link: It is added to <a> tag to make the whole component clickable.

Syntax:

<div class="card">
    ...
    <a href="#" class="btn stretched-link">...</a>
</div>

Example 1: The class stretched-link is added to <a> tag to make the whole component clickable.

HTML




<html>
  
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
    <link href=
          rel="stylesheet">
    <script src=
    </script>
</head>
  
<body> 
    <div class="text-center">
        <h1 class="text-success">GeeksforGeeks</h1>
        <h2>Bootstrap 5 Stretched link</h2>
    </div>
    <br><br>
    <div class="col d-flex justify-content-center">
        <div class="card w-25">
            <div class="card-body">
                <h3 class="card-title text-center 
                    text-success">
                    GFG
                </h3>
                <p class="card-text">
                    A computer science portal for geeks
                </p><hr>
                Practice: 
                <a href="#" class="stretched-link">
                    Problem of the Day
                </a>
            </div>
       </div>
    </div>
</body>
</html>


Output:

Bootstrap 5 Stretched link

Bootstrap 5 Stretched link

Example 2: If a stretched-link does not work then it is because of a containing block,

HTML




<html>
  
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1.0">
    <link href=
          rel="stylesheet">
    <script src=
    </script>
</head>
  
<body>
    <div class="text-center">
        <h1 class="text-success">GeeksforGeeks</h1>
        <h2>Bootstrap 5 Stretched link</h2>
    </div>
    <br><br>
    <div class="col d-flex justify-content-center">
        <div class="card w-25">
            <div class="card-body">
                <h5 class="card-title">GFG</h5>
                <p class="card-text">
                    A computer science portal for geeks
                </p>
                <p class="card-text">
                    <a href="#" class="btn stretched-link text-danger">
                        Stretched link will not work here
                    </a>
                </p>
                <p class="card-text bg-light text-success">
                    This <a href="#" class="btn stretched-link">
                        stretched link
                    </a> will only work in this p tag.
                </p>
            </div>
        </div>
    </div>
</body>
  
</html>


Output:

Bootstrap 5 Stretched link

Bootstrap 5 Stretched link

Reference: https://getbootstrap.com/docs/5.0/helpers/stretched-link/



Previous Article
Next Article

Similar Reads

ReactJS MDBootstrap Stretched Link Utilities
MDBootstrap is a Material Design and bootstrap-based react UI library that is used to make good-looking webpages with its seamless and easy-to-use component. In this article, we will know how to use Stretched Link Utilities in ReactJS MDBootstrap. The Stretched Link Utilities is used to make a component and add a link to it. Syntax: <a class="st
2 min read
React Suite Breadcrumb Used with Link in next/link
React Suite is a popular front-end library with a set of React components that are designed for the middle platform and back-end products. The Breadcrumb component is used for Navigation purposes. We can display the current page path and quickly return to the history page. Breadcrumbs can be used with Links also. This will help to add on all the fu
3 min read
React Suite Pagination Used with Link in next/link
React suite is a library of React components, sensible UI design, and a friendly development experience. It is supported in all major browsers. It provides pre-built components of React which can be used easily in any web application. In this article, we'll learn about React suite Pagination Used with Link in next/link. The pagination has a layout
2 min read
React Suite Nav Used with Link in next/link
React Suite is a popular front-end library with a set of React components that are designed for the middle platform and back-end products. Nav Provides a list of various forms of navigation menus, which can be landscape and portrait layouts. Nav Items can be used with Links also. These can be used for any redirection. Syntax: <Nav > <Nav.I
3 min read
How to Create HTML Link that does not Follow the Link ?
An HTML link, a hyperlink, connects one web page to another. Users who click an HTML link are taken to the corresponding web page. Web developers can link to text, images, and other media using HTML links. These are the following approaches: Table of Content Using the href Attribute with a Placeholder ValueUsing the href Attribute with an Empty Val
2 min read
How to hide admin login link to custom link of WordPress website ?
WordPress security is crucial for website owners. One effective way to enhance security is by customizing the login URL for your WordPress admin panel. In this article, we’ll explore how to hide the default login link and replace it with a custom one. In WordPress, the login URL is like this e.g. www.yourwebsite.com/wp-admin here this string /wp-ad
4 min read
How to make whole row in a table clickable as link in Bootstrap ?
Tables in Bootstrap can be formed either using traditional <table> tags or using the in-built 'grid' system. Earlier, <table> tags were often employed to designing grids for the sites, but nowadays with flexbox and table display properties in CSS, it is easier to just use divs. In the following examples, we'll see how to make a complete
3 min read
How to apply custom color to glyphicon icon embed within a link styled with Bootstrap ?
Given an HTML document with relevant Bootstrap glyphicon and the task is to apply the custom color to them. Approach: First, we need to assign the id attribute to the particular glyphicon which you need to customize by using CSS. We can apply the color property to the particular id and change the icon color by using a hex value or normal color. The
2 min read
Bootstrap 5 Alerts Link color
Bootstrap 5 Alerts Link Color class is used to set the color of the alert element. There are different kind of alerts that indicates different things, if there is a success then the color of the alert will be green, if it's a failure then it should show a red color alert. Each color of the alert represents something. Alert color should be its name,
3 min read
Create Button Like a Link with Bootstrap 5
Bootstrap 5 has various classes that can be used to create different elements with highly customizable styling. By using Bootstrap Classes, we can create a button that looks similar to the link. In this article, we will create a button that looks like a link with Bootstrap 5 classes. We will explore two different approaches with their Syntax, and p
2 min read
Include Bootstrap in AngularJS using ng-bootstrap
AngularJS can be integrated with Bootstrap CSS and Javascript and can be used to create creative forms, tables, navigation bars, etc. Steps: Make sure the Angular CLI present in your system if not then run the command in the terminal to do so. npm install -g @angular/cli Create a new project on visual studio code by running the code ng new project-
2 min read
Difference between bootstrap.css and bootstrap-theme.css
Bootstrap is an HTML, CSS and JS front-end-framework used for developing responsive and mobile-first projects on the web. It is the framework that comes up with predefined terms, thus giving you the ability to use these codes instead of having to create the codes from scratch. It is a collection of HTML, CSS and JS code that is designed to help bui
5 min read
Difference Between Bootstrap 3 and Bootstrap 4
Bootstrap: Bootstrap was developed by Mark Otto and Jacob Thorton at Twitter in August 2011. It is an open-source framework that is used to design responsive websites faster and easier. It is the most popular open-source framework that includes HTML, CSS, and JavaScript. It can create web applications with any server-side Technology like Java, PHP,
2 min read
Difference between Bootstrap 4 and Bootstrap 5
What is Bootstrap? It is an open-source framework from late 2011 that is used for designing responsive websites with a mobile-first approach faster and easier. Bootstrap is available for HTML, CSS, and JS. According to server-side languages like PHP, Node, etc. bootstrap helps to design the frontend. Bootstrap has made the work for developers easie
3 min read
Bootstrap Cheat Sheet - A Basic Guide to Bootstrap
Bootstrap is a free, open-source, potent CSS framework and toolkit used to create modern and responsive websites and web applications. It is the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites. Nowadays, websites are perfect for all browsers and all sizes of screens. What is Bootstrap Cheat Sheet?A
15+ min read
Node.js fs.link() Method
The fs.link() method is used to create a hard link to the given path. The hard link created would still point to the same file even if the file is renamed. The hard links also contain the actual contents of the linked file. Syntax: fs.link( existingPath, newPath, callback ) Parameters: This method accepts three parameters as mentioned above and des
2 min read
PHP | link( ) Function
The link() creates a hard link for a specified target. The target and the link are passed as parameters to the link() function and it returns true on success and false on failure.Syntax: link(target, link) Parameters Used: The link() function in PHP accepts two parameters. target : It is a mandatory parameter which specifies the target.link : It is
2 min read
HTTP headers | Link
For serialising one or more links in HTTP headers, the HTTP Link header-field is used. It allows the server to point an interested client to another resource containing metadata about the requested resource. It is semantically equivalent to the HTML <link> element. Syntax: Link: <uri-reference>; param1="value1" param2="value2" Directive
1 min read
HTML | DOM Link Object
HTML DOM Link Object is used to access HTML <link> element.Syntax: To Access a HTML element: document.getElementById("myLink"); To Create a New HTML element: document.createElement("LINK"); Property Values: ValueDescriptioncharsetIt assigns the character encoding of the linked documentcrossOriginIt assigns the the CORS settings of the linked
2 min read
HTML | DOM Link disabled Property
The DOM Link disabled Property is used to set or return whether the linked document is disabled or not. This Property is only used with stylesheet links. Syntax: It return the disabled property:. linkObject.disabledIt is used to set the disabled property. linkObject.disabled = true|false Property Values: true: It specify that the linked document wi
2 min read
HTML | DOM Link type Property
The DOM Link type Property is used to set or return the content type or MIME type of the linked Document. For eg. text/css", "text/javascript", "image/gif", etc. Syntax: It returns the type property.linkObject.typeIt is used to set the type property.linkObject.type = MIME-type Property Values: It contains the value i.e MIME-type which is used to sp
1 min read
HTML | DOM Link sizes Property
The HTML | DOM Link sizes Property is used For returning the value of the sizes attribute of a linked document. The sizes attribute is used to specify the sizes of the icon for visual media and it only works when rel="icon". It is read-only Property. Syntax: linkObject.sizes Return Value: It returns the size of the icon. Example: This Example retur
1 min read
HTML | DOM Link hreflang Property
The DOM Link hreflang Property is used to set or return the value of the hreflang attribute of a linked document. The hreflang attribute is used to specify the language for a linked document. Syntax: It return the hreflang property.linkObject.hreflangIt is used to set the hreflang property.linkObject.hreflang = languagecode Property Values: It cont
2 min read
HTML | DOM Link href Property
The HTML | DOM Link href Property is used to set or return the URL of a Linked Document. Syntax: It return the href property.linkObject.hrefIt is used to Set the href property.linkObject.href = URL Property Values: It contains the value i.e URL which specify the URL of the link. absolute URL: It points to another website.relative URL: It points to
2 min read
HTML | DOM Link rel Property
The HTML | DOM Link rel Property in HTML DOM is used to set or return the value of the rel attribute of a linked document. The rel attribute is used to specify the relation between the current document and the linked document. Syntax: It returns the rel property.linkObject.relIt is used to set the rel property.linkObject.rel = relationship Property
3 min read
HTML | <link> href Attribute
The HTML <link> href Attribute is used to specify the URL of the linked document. It mostly contains the URL of the stylesheet file. Syntax: <link href="URL"> Attribute Values: It contains the value i.e URL which specifies the URL of the linked document. Possible values are: absolute URL: It points to another website.Relative URL: iT po
1 min read
HTML | <link> sizes Attribute
The HTML link sizes Attribute is used to specify the sizes of the icon for visual media and it only works when rel=”icon”. It is a read-only Property. Syntax: <link sizes="HeightxWidth | any"> Attribute Values HeightxWidth It is used to specify the one or more sizes of a linked icon. The value of the height and the width are separated by an "
1 min read
How to display confirmation dialog when clicking an <a> link using JavaScript / jQuery ?
Given <a> element and the task is to display the confirmation message when clicking the <a> link, with the help of JavaScript and jQuery. Display confirmation dialog when clicking an <a> link using JavaScript onclick Event: This event occurs when the user clicks on an element. Syntax: In HTML: <element onclick="myScript"> In
5 min read
HTML | <body> link Attribute
The HTML <body> link Attribute is used to specify the default color for a unvisited link in a document. Note : The HTML <body> link attribute is not supported by HTML5. Instead of using this attribute we can use CSS | :link Selector Syntax: <body link="color_name|hex_number|rgb_number"> Attribute Values: color_name: It is used to
1 min read
HTML | <link> target Attribute
The HTML <link> target Attribute is used to specify the window or a frame where the linked document is loaded. It is not supported by HTML 5. Syntax: <link target="_blank|_self|_parent|_top|framename"> Attribute Values: _blank: It opens the link in a new window. _self: It is the default value. It opens the linked document in the same fr
1 min read