How to Remove Href Values from Chrome Print Output?

Susan Sarandon
Release: 2024-11-02 08:36:03
Original
237 people have browsed it

How to Remove Href Values from Chrome Print Output?

Removing Href Values in Chrome Print Output

When customizing print CSS in Chrome, you may encounter an issue where links are printed with both the textual content and the href value. To resolve this, follow these steps:

For reference, here's the initial HTML:

<a href="http://www.google.com">Google</a>
Copy after login

Bootstrap's Default Behavior:

Bootstrap includes a print stylesheet that appends the href value to links in parentheses:

@media print {
  a[href]:after {
    content: " (" attr(href) ")";
  }
}
Copy after login

Disabling or Overriding Bootstrap's Style:

To remove the href values, you can either modify Bootstrap's print stylesheet or override it in your own:

Disabling Bootstrap's Style:

Remove the a[href]:after rule from Bootstrap's print stylesheet.

Overriding the Style:

Add a new a[href]:after rule to your own print stylesheet and set content: none !important; to disable Bootstrap's styling:

@media print {
  a[href]:after {
    content: none !important;
  }
}
Copy after login

After implementing these changes, links will print only the textual content, as desired:

Google
Copy after login

The above is the detailed content of How to Remove Href Values from Chrome Print Output?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!