Is it possible to apply a style to an HTML element using only its title as a unique identifier? For example:
<div class="my_class">
<a href="some site" title="MyTitle">My Link</a>
</div>
I would like to write a rule that will apply only to link element within a div of class my_class and the link title MyTitle.
I do not have the ability to change page layout, however, I can use a custom CSS file that is included automatically.
Thank you
You can't style an actual title attribute How the text in the title attribute is displayed is defined by the browser and varies from browser to browser. It's not possible for a webpage to apply any style to the tooltip that the browser displays based on the title attribute.
CSS [attribute~=value] Selector The [attribute~=value] selector is used to select elements with an attribute value containing a specified word.
For this content, we'll use the <h1> heading element, the <p> paragraph element, and the <em> emphasis element. Make sure to change the text with your own information. The elements used in this code snippet apply some light styling to our title and subtitle.
It sure is, using what's called attribute selectors; these are part of CSS2. In your particular case, you'd use:
div.my_class a[title="MyTitle"] { color: red; }
You can read more about attribute selectors here: http://www.w3.org/TR/CSS2/selector.html#attribute-selectors
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With