DavidTheExpert
DavidTheExpert

Reputation: 23

How to redefine a CSS class for the whole document?

So I've got style.css which defines all my CSS classes. But I want to redefine a class for an entire page without modifying style.css. I know I could override the CSS properties by using the style attribute on each element, but I don't want to do that.

So let's say I've got the class colortext defined in style.css with color:blue; but I want it to be color:red; for one entire page. How can I accomplish this?

Upvotes: 1

Views: 5933

Answers (4)

Bryan A
Bryan A

Reputation: 3634

You could always place a

<style type="text/css">
    .colortext { color: red; }
</style>

in your HTML document somewhere inside the <head> tag... however I'd recommend simply adding a rule to your stylesheet, if possible.

Upvotes: 4

ninMonkey
ninMonkey

Reputation: 7511

Override is an option

* { color:red !important; }

This isn't a good way, ( but, I thought it sounded like he was implying he didn't wan't to use ids or classs )

Upvotes: -1

Rohit Azad Malik
Rohit Azad Malik

Reputation: 32192

Now define your body id and do this css as like this

<body id="home">
<p class="red">hello</p>
</body>

Css

#home .red{
color:red;
}

Upvotes: 1

Miqdad Ali
Miqdad Ali

Reputation: 6147

add style tag top of your head closing tag and create same class add each element with !important

   .old_class{
        color: new_value !important;
    }

Upvotes: -1

Related Questions