Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to force a style to a div element which already has a style="" attribute

Tags:

html

css

I'm trying to skin HTML output which I don't have control over. One of the elements is a div with a style="overflow: auto" attribute.
Is there a way in CSS to force that div to use overflow: hidden;?

like image 674
Martin Plante Avatar asked Sep 19 '08 18:09

Martin Plante


People also ask

How do I apply a style tag to a div?

The <div> tag defines a division or a section in an HTML document. The <div> tag is used as a container for HTML elements - which is then styled with CSS or manipulated with JavaScript. The <div> tag is easily styled by using the class or id attribute. Any sort of content can be put inside the <div> tag!

How do I force an element inside a div?

Just add overflow: auto; to the <ul> . That will make it so that the text doesn't leak outside of the UL. However, depending on what you're doing, it might be easier to just make the <li> display: inline; . It totally depends on what you're doing!

Can you style a div?

You'll primarily use the div tag to group similar content together so you can style it easily. A great example of this is using div to group different sections of a webpage together. You can put together the header, nav, sections, and footer of a page in an individual div tag so they can be styled together.


1 Answers

You can add !important to the end of your style, like this:

element {     overflow: hidden !important; } 

This is something you should not rely on normally, but in your case that's the best option. Changing the value in Javascript strays from the best practice of separating markup, presentation, and behavior (html/css/javascript).

like image 113
Magnar Avatar answered Sep 20 '22 16:09

Magnar