Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

styling additional <hr> tag?

Tags:

css

styling

I am looking to style an additional <hr> tag for my side-bar on my website.

How might I be able to do this if I already have an hr defined?

hr { border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 22px 0 21px; height: 0; }

Could I add a style?

hr.side { border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 22px 0 21px; height: 0; }

so html would be

<hr class="side"> ?

like image 287
user1676691 Avatar asked Nov 20 '12 03:11

user1676691


People also ask

Can I style an HR tag?

The HTML <hr> element is a block-level element and represents a horizontal rule. It creates a horizontal line. We can style the horizontal line by adding color to it.

Can you style HR tag in CSS?

You can simply use the CSS background-color property in combination with the height and border to the change the default color an <hr> element. In the following example we've changed the color of hr tag to light grey. You can also increase the thickness of the line by simply increasing the value of the height property.

Can we add class to HR tag?

The class attribute assigns one or more classnames to the <hr> tag. Classnames are defined in a stylesheet or in a local <style> element. Classes, i.e. classnames, are used to style elements.


1 Answers

use

hr.side { border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 22px 0 21px; height: 0; }

then

<hr class="side">

in css the . refers to a class , and # to id

EDIT:

if you really really wanted to do inline styling with style="" then it would look like this

<hr style="border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 22px 0 21px; height: 0;">

This last method is not really the recommended way, but works great if you want to override all css style sheets, and also override any <style> </style> tags that are embedded in HTML page

like image 86
Scott Selby Avatar answered Nov 03 '22 03:11

Scott Selby