css - Need to remove href values when printing in Chrome

ID : 10439

viewed : 26

Tags : cssprintinghyperlinkprint-csscss

Top 5 Answer for css - Need to remove href values when printing in Chrome

vote vote

100

Bootstrap does the same thing (... as the selected answer below).

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

Just remove it from there, or override it in your own print stylesheet:

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

83

It doesn't. Somewhere in your print stylesheet, you must have this section of code:

a[href]::after {     content: " (" attr(href) ")" } 

The only other possibility is you have an extension doing it for you.

vote vote

76

@media print {     a[href]:after {        display: none;        visibility: hidden;     }  }

Work's perfect.

vote vote

64

If you use the following CSS

<link href="~/Content/common/bootstrap.css" rel="stylesheet" type="text/css"    /> <link href="~/Content/common/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="~/Content/common/site.css" rel="stylesheet" type="text/css" /> 

just change it into the following style by adding media="screen"

<link href="~/Content/common/bootstrap.css" rel="stylesheet" **media="screen"** type="text/css" /> <link href="~/Content/common/bootstrap.min.css" rel="stylesheet" **media="screen"** type="text/css" /> <link href="~/Content/common/site.css" rel="stylesheet" **media="screen"** type="text/css" /> 

I think it will work.

the former answers like

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

were not worked well in the chrome browse.

vote vote

57

I encountered a similar problem only with a nested img in my anchor:

<a href="some/link">    <img src="some/src"> </a> 

When I applied

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

I lost my img and the entire anchor width for some reason, so instead I used:

@media print {    a[href]:after {       visibility: hidden;    } } 

which worked perfectly.

Bonus tip: inspect print preview

Top 3 video Explaining css - Need to remove href values when printing in Chrome

Related QUESTION?