Unstyling <hr> when it's wrapped in a div - html

I have a div that wraps around my <footer> tag. In the div is an <hr>, which needs to be in the div to have the positioning properties applied. However, it also carries over the coloring of the links in my footer. I don't want the <hr> to be the same color as the links. Is there any way to "escape" this or change the property.
I tried <hr style="color: black;"> but that didn't change anything. If you have any input on how to change the properties despite the set CSS in the div, I would greatly appreciate it.
JS Fiddle: http://jsfiddle.net/o6vmz7t5/1/
HTML
<div id="footer_style">
<hr>
<footer>
Contact
Privacy Policy
Create Account
</footer>
</div>
CSS
#footer_style {
margin: 0 auto;
position: fixed;
bottom:0;
width: 100%;
padding: 20px;
}
#footer_style a {
color: #f2f0e1;
}
#footer_style a:hover {
color: black;
}

hr tags simply have a border-top applied on them
override the hr as below
#footer_style hr {
border-top: 1px solid black;
}

#footer_style hr {
background-color: black;
height:1px;
}
JSFiddle

Whoa, it had me struggling for a minute. Apparently since the hr has no height and you cant see its internal "fill", affecting the color does nothing.
What you actually see is the border, so using border-color did it for me.

Please try below code I have try this code. Using this code solve your problem.
border-color: red;

Instead Using the color: black;
Try using in this way
border: 1px solid #000;
border-width: 1px 0px 0px 0px;
Try it

Related

hr element does not display/makes view blank ionic

How to make a hr element appear at ionic framework? When i do hr, it shows nothing/invisible, or view get's blank.
There is a ionic compenent to make hrs (v1)? If there is, which one?
Thanks in advance.
Use this to test if it would show up;
hr {
border: 2px solid red !important;
height: 10px !important;
width: 500px !important;
background: blue !important;
display: block !important;
font-size: 2em !important;
opacity: 1 !important;
visibility: visible !important;
}
Note: This is just a test. using "!important" is not ideal. From here you should try and determine why it is not showing
I don't have much experience with Ionic, but you could try to define a CSS class that renders exactly the same thing as <hr /> element. I think that should work.
.hr {
border-bottom: 1px solid #ccc;
margin: 10px 0;
width: 100%;
}
<div class="hr"> </div>
https://jsfiddle.net/6qs02538/
In Ionic 4 you also need to set a background-color for the hr, e.g.:
hr {background: black;}
if anyone is still facing this problem , use ion-item-divider tag
I am using bootstrap.min.css other than that I have no reason for <hr /> to not show up. However, I need the code below to see a thin line. Setting the visibility and background did nothing.
hr {
border-bottom: 1px solid #ccc;
margin: 10px 0;
width: 100%;
}
Notice how I am not using a class to set the properties. I just use <hr/> directly in the html. (In the answer above s/he uses a class name and applies it to an div. As such, <div class="hr">

Is this possible with HTML?

I need to implement a menucard in to a website. My customer wants, that it looks exactly like on the card in the restaurant.
Is it with HTML possible to put a border-line directly under the text like on the image below ("Hauptgerichte")? And if yes, how could I realize that?
Thanks!
If you want the border to touch the text, you can adjust the line-height to something small:
p
{
border-bottom: 1px solid black;
line-height: 10px;
}
http://jsfiddle.net/kz43g/
Here is 1 variant - here is a fiddle.
html:
<div>
<p> some text </p>
</div>
css:
*{
padding:0;
margin:0;
}
div{
border-bottom:1px solid #000;
}
p{
margin-bottom:-5px;
}
i just put negative bottom margin to the text container (in this case the p tag)
This is possible in HTML / CSS: Example
HTML:
<h3 class="yourClass">Text place</h3>
CSS :
.yourClass{
width:300px;
border-bottom: 1px solid #000;
text-indent:50px;
line-height:80%;
}
In this example I'm changing the line height to move the text under the line and the then using text-indent to move it to the correct positioning. It should give you the desired results. There are a few ways to do this, but this will require less HTML.
Here is a JS Bin that shows how this could be done. I added a border to the bottom of the paragraph and a little padding to the left. Then I changed the line height of the paragraph so it would sit right on the border.
You could try working with:
text-decoration: underline;
I choose to use the border property for easy customization.
CSS from JS Bin:
p {
border-bottom:1px solid #333;
line-height: 50%;
padding: 0 0 0 40px;
}
Pure CSS solution is possible with pseudoelement after, see fiddle. The distance from text is done by the bottom:3px:
.underline {
position:relative;
}
.underline::after {
content: '';
width: 100%;
position:absolute;
bottom: 3px;
left:0;
border-bottom: 1px solid black;
}
edit: the line-height solution looks better :)
Put the text inside of a div. Then, make the div a set width. Then, add a border to the div.
<div id="title">
<h2> Hauptgerichte </h2>
</div>
/*CSS*/
#title{
width: 50px;
border-bottom: 2px solid #000000;
}
Put the header in H tags, then target the H tag with CSS and apply border bottom.
HTML
<div id="content">
<h1>title</h1>
</div>
CSS
#content h1{
Border-bottom:1px solid #999;
Width: 150px;
}

horizontal line and right way to code it in html, css

I need to draw a horizontal line after some block, and I have three ways to do it:
1) Define a class h_line and add css features to it, like
#css
.hline { width:100%; height:1px; background: #fff }
#html
<div class="block_1">Lorem</div> <div class="h_line"></div>
2) Use hr tag
#css
hr { width:100%; height:1px; background: #fff }
#html
<div class="block_1">Lorem</div> <hr />
3) use it like a after pseudoclass
#css
.hline:after { width:100%; height:1px; background: #fff; content:"" }
#html
<div class="block_1 h_line">Lorem</div>
Which way is the most practical?
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #ccc;
margin: 1em 0;
padding: 0;
}
<div>Hello</div>
<hr/>
<div>World</div>
Here is how html5boilerplate does it:
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #ccc;
margin: 1em 0;
padding: 0;
}
I'd go for semantic markup, use an <hr/>.
Unless it's just a border what you want, then you can use a combination of padding, border and margin, to get the desired bound.
.line {
width: 53px;
height: 0;
border: 1px solid #C4C4C4;
margin: 3px;
display:inline-block;
}
<html>
<body>
<div class="line"></div>
<div style="display:inline-block;">OR</div>
<div class="line"></div>
</body>
</html>
In HTML5, the <hr> tag defines a thematic break. In HTML 4.01, the
<hr> tag represents a horizontal rule.
http://www.w3schools.com/tags/tag_hr.asp
So after definition, I would prefer <hr>
If you really want a thematic break, by all means use the <hr> tag.
If you just want a design line, you could use something like the css class
.hline-bottom {
padding-bottom: 10px;
border-bottom: 2px solid #000; /* whichever color you prefer */
}
and use it like
<div class="block_1 hline-bottom">Cheese</div>
I wanted a long dash like line, so I used this.
.dash{
border: 1px solid red;
width: 120px;
height: 0px;
}
<div class="dash"></div>
My simple solution is to style hr with css to have zero top & bottom margins, zero border, 1 pixel height and contrasting background color.
This can be done by setting the style directly or by defining a class, for example, like:
.thin_hr {
margin-top:0;
margin-bottom:0;
border:0;
height:1px;
background-color:black;
}
it is depends on requirement , but many developers suggestions is to make your code as simple as possible .
so, go with simple "hr" tag
and CSS code for that.
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #ccc;
margin: 1em 0;
padding: 0;
}
<div>Hello</div>
<hr/>
<div>World</div>
emphasized text
This is relatively simple example and worked for me.
hr {
width: 70%;
margin-left: auto;
margin-right: auto;
}
Resource: https://www.w3docs.com/snippets/css/how-to-style-a-horizontal-line.html

Simple questiong regarding styling of <hr/> tag

I am using a hr tag on our page but it looks weird in
IE9 http://img580.imageshack.us/img580/1295/unleddlz.png
Notice the left-hand-side
CSS is
.greyLine {color: rgb(252,252,252); height: 1px; background-color: rgb(252,252,252);}
What's wrong here?
Thanks in advance.
.greyLine
{
border: none;
border-top: 1px solid rgb(252,252,253);
}
.greyLine {
height: 1px;
color: rgb(252,252,252);
background-color: rgb(252,252,252);
border: none;
}
You had it right, just needed to remove the border. Doing it your way plus border:none allows you to change the height if needed. Good luck. Source: How To Style HR with CSS

html css what is the modern line?

What is the modern way of making a line half way across the screen? I saw this in a tutorial and it looks a bit old fashioned now.
Like:
<hr size="6" width="50%">
How would you do something similar if you were making a webpage now?
You can continue to use <hr />, but I would suggest omitting the inline attributes. It is just another element, and you can move your styling information to css:
hr {
width:50%;
}
You can use CSS to style the line
hr{
width:50%;
}
HTML:
<hr />
CSS:
hr { width: 50%; }
This should be controlled in CSS using something like:
hr {
width: 50%;
}
You can change borders etc too. Just make sure you reset the borders and backgrounds as different browsers use different methods to style it
Using a <div> and some styling:
#line {
width: 50%;
margin: 0 auto; /* Centered */
height: 4px; /* The border adds to height */
border: 1px solid #888888;
border-bottom: 1px solid #E9E9E9;
border-right: 1px solid #E9E9E9;
}