I am using <hr /> element in my HTML. In Bootstrap.css file they applied some styles to <hr /> tags. I don't want to apply those styles to one of my <hr /> tag. How can I do that?
-
Can you show us the CSS and HTML?Siyah– Siyah2014-03-05 08:03:19 +00:00Commented Mar 5, 2014 at 8:03
-
1Override the applied styles for that particular element.Hashem Qolami– Hashem Qolami2014-03-05 08:03:24 +00:00Commented Mar 5, 2014 at 8:03
-
You can customize your bootstrap...Mr. Alien– Mr. Alien2014-03-05 08:06:06 +00:00Commented Mar 5, 2014 at 8:06
-
But I need those styles for other hr elements, I just want to avoid it to perticular hr taguser3191903– user31919032014-03-05 08:06:46 +00:00Commented Mar 5, 2014 at 8:06
10 Answers
Suppose you have an id to the div enclosing the hr
<div id="hrDiv">
<hr>
</div>
To remove style you can use removeAttr property over the selector
$("#hrDiv hr").removeAttr("style");
If you are not using inline style then you need to override the propeties in css
#hrVid hr
{
//oveeride property
}
You can also put id to hr tag directly
5 Comments
Simply override the styles.
Say bootstrap applies:
hr{ border: 1px solid red; padding: 10px; }
In a stylesheet declared after bootstrap, override then like this:
hr{ border: none; padding: 0; }
Edited addition:
Based on the replies, if it's a particular HR tag (but not all), give the specific one a class:
<hr class="specialHr" />
And apply the style:
hr.specialHr{ border: none; padding: 0; }
1 Comment
You can't do that.
You have to override every CSS property explicitly.
You can also modify your css file to create a class (instead of applying the style to all tags). However, you must explicitly declare this class in each <hr> tag where you want to apply the style (inverted your problem)
Comments
I would suggest you edit the Bootstrap CSS so that you need to add a class in order to get the BootStrap styling e.g. <hr class="hr">
hr.hr {
margin-top: 20px;
margin-bottom: 20px;
border: 0;
border-top: 1px solid #eee;
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
You can also create a class that specify the default styling to override Bootstrap. The default styling can differ from different browsers so I guess you need to decide which one to use. I took this from the user agent stylesheet in Chrome.
hr.hr {
display: block;
-webkit-margin-before: 0.5em;
-webkit-margin-after: 0.5em;
-webkit-margin-start: auto;
-webkit-margin-end: auto;
border-style: inset;
border-width: 1px;
}
If you take that and make a CSS style rule specifying the same appearance you could mimic the default styling for that browser.
Comments
at the end of your tag override with !important
example
<hr style="width:200px" !important>
this will overide with your changes
1 Comment
There are few approaches... Give this particular < hr /> a class (or id) and add your styles in your css:
<hr class="myspecialhr" />
<style>
.myspecialhr {height:5px;}
</style>
You could also add you style overrides inline with the element:
<hr style ="height:5px;"/>
You could "tag" this < hr /> with the class or id of a parent item of that particular page.
<div class ="page1">
<hr />
</div>
<style>
.page1 hr {height:5px;}
</style>
Finally, you could use CSS borders to achieve your layout goals and replace the
in your pages.
Comments
I think you can do this now:
hr {
all: reset;
}
1 Comment
all: revert?