Reputation: 2736
I have following div:
<div class="mydiv">
This is some introduction text
<br />
click me
</div>
Is it possible to style the click me
differently than the rest of the div using CSS only?
Upvotes: 5
Views: 5249
Reputation: 22171
You can style the :first-line
differently. If there's only 2 lines, it's kind of feasible to style the 2nd and last line than the first one in pure CSS.
BUT
+1 to Pevara suggestion: it should be a link or a button and then it can easily be styled
div {
text-transform: uppercase;
font-size: 2rem;
color: red;
}
div::first-line {
text-transform: initial;
font-size: 1rem;
color: initial;
}
<p>OK</p>
<div class="mydiv">
This is some introduction text
<br />
click me
</div>
<hr>
<p>#fail</p>
<div class="mydiv" style="width: 100px; border: 1px dotted blue">
This is some introduction text
<br />
click me
</div>
Upvotes: 13
Reputation: 207900
No, without modifying the HTML or using JavaScript there is no pure CSS way to select the text click me
.
Upvotes: 1