user5405873 user5405873 - 1 month ago 13
CSS Question

How to always display the alt attribute of an anchor tag

How to always display the alt attribute of an anchor tag in HTML?

Here is a situation where I have multiple repeating grids and I want to identify with date.

So i want to show the title always, how can I achieve this?

<a href="#" title="created at 12 october">see details</a>
<a href="#" title="created at 13 october">see details</a>
<a href="#" title="created at 14 october">see details</a>


Here is a demo: https://jsfiddle.net/wub5y96d/1/

Answer

You can output the content of an element's attribute using content: attr(attribute); on either of the pseudo elements ::after or ::before, like this:

a[title]::after {
  content: ' ('attr(title)')';
}

Demo