redleaf
redleaf

Reputation: 425

Edit CSS of text that has no class or id

This seems like it should be simple enough, but using pure CSS how could I edit a line of text (in this case printed by a script) that has no html tag, CSS class or id?

This is the HTML I'm working with:

<div class="price">
    <h4>
       <span class="amount">
           <span class="currencySymbol">$</span>
           18.06
       </span>
       <!--EDIT THIS LINE -->  &nbsp;(as of Nov 1, 2017, 1:37 am)                   
    </h4>
</div>

Upvotes: 1

Views: 1329

Answers (3)

Reinhard
Reinhard

Reputation: 75

Your text is enclosed in the h4 tag which itself is inclose in div.price.

So if you do not wish to put a default style on the html or body tag, you could use

.price > h4 {
    /* style for text in <h4> */
}
.amount {
    /* different style for text in the <span>, if required */
}

Upvotes: 0

Seb
Seb

Reputation: 121

You can edit the properties of the text without editing the actual text itself if that's what you're looking for? Whatever you set for h4, counteract it with h4 span.amount, like so:

h4 {
   color: green;
}

h4 span.amount {
   color: red;
} 

Upvotes: 2

shafikshaon
shafikshaon

Reputation: 6414

This is not possible. You need a selector to apply css property. But there is is an another to do this but this is not the smart way. See the following example

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    Lorem ipsum dolor sit amet
</body>
</html>
<style type="text/css">
    *{
        text-align: center;
    }
</style>

Upvotes: 0

Related Questions