With CSS it is possible yes, but you will need to remove the styling inline element, this is because the style defined in the attribute style
has higher priority than styles defined in the CSS, being impossible to overwrite them (without using the !important
).
a.obs-aluno {
display: none;
}
td.aluno:hover > a.obs-aluno {
display: inline;
}
<table>
<tr>
<td class="aluno" style="text-transform:uppercase">
Fulano
<a class="obs-aluno" href="#modal-obs">Link</a>
</td>
</tr>
</table>
Using the !important
is possible, but its use should be avoided, as it may cause debugging problems in the future.
td.aluno:hover > a.obs-aluno {
display: inline !important;
}
<table>
<tr>
<td class="aluno" style="text-transform:uppercase">
Fulano
<a class="obs-aluno" href="#modal-obs" style="display: none">Link</a>
</td>
</tr>
</table>
It is important to highlight the order of priority of styles:
- Styles inline, defined in
style
;
- Styles in CSS defined with id;
- Styles in CSS defined with class;
- Styles in CSS defined for the element;
See the examples below:
- With all styles applied to the same elements, the style will be prioritized
inline
.
a {
color: blue;
}
.yellow {
color: yellow;
}
#green {
color: green;
}
<a href="#" style="color: red" class="yellow" id="green">Link</a>
- With id, class, and element styles applied, id will be prioritized.
a {
color: blue;
}
.yellow {
color: yellow;
}
#green {
color: green;
}
<a href="#" class="yellow" id="green">Link</a>
- With class and element styles applied, the class will be prioritized.
a {
color: blue;
}
.yellow {
color: yellow;
}
#green {
color: green;
}
<a href="#" class="yellow">Link</a>
- The style of the element is only applied when no other is present.
a {
color: blue;
}
.yellow {
color: yellow;
}
#green {
color: green;
}
<a href="#">Link</a>
Additional reading
Which css selector has priority
Excellent, but with pure CSS is possible? If it is that answer served me well!
– Thiago