0

I am trying to apply style for title attribute of a span tab. The span is already using a style class i want to use the same class to apply my style is it possible ?

<span class="span_class" title="100"> hello </span>

.span_class {

}

I want to change the background colour of the title.

1 Answers1

0

the question is answered here: How to change the style of Title attribute inside the anchor tag?

alternatively, you should use a javascript library (there are several of them) like https://jqueryui.com/tooltip/

I think you should also add the aria-label attribute to ensure accessibility.

Can you use scss to have the same style? Something like that?

@mixin myclassforspan{
  background:blue;
  color:white;
  padding:10px 2px;
}

.span_class[title] {
  @include  myclassforspan;
  &:hover{
    position: relative; 
    &:after{
      @include  myclassforspan;
      content: attr(title);  
      position: absolute;
      left: 0;
      top: 100%;
      z-index: 20; 
    }    
  }
}
Community
  • 1
  • 1