How to customize hr tag in html

How TO - Style HR (Horizontal Ruler/Line)


Learn how to style an hr element with CSS.








Horizontal Line

You can use the border property to style a hr element:

Example

/* Red border */
hr.new1 {
  border-top: 1px solid red;
}

/* Dashed red border */
hr.new2 {
  border-top: 1px dashed red;
}

/* Dotted red border */
hr.new3 {
  border-top: 1px dotted red;
}

/* Thick red border */
hr.new4 {
  border: 1px solid red;
}

/* Large rounded green border */
hr.new5 {
  border: 10px solid green;
  border-radius: 5px;
}

Try it Yourself »


The HTML hr tag.



Example

Use the


tag to define thematic changes in the content:

The Main Languages of the Web

HTML is the standard markup language for creating Web pages. HTML describes the structure of a Web page, and consists of a series of elements. HTML elements tell the browser how to display the content.


CSS is a language that describes how HTML elements are to be displayed on screen, paper, or in other media. CSS saves a lot of work, because it can control the layout of multiple web pages all at once.


JavaScript is the programming language of HTML and the Web. JavaScript can change HTML content and attribute values. JavaScript can change CSS. JavaScript can hide and show HTML elements, and more.

Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

The


tag defines a thematic break in an HTML page (e.g. a shift of topic).

The


element is most often displayed as a horizontal rule that is used to separate content (or define a change) in an HTML page.


Browser Support

Element

Yes Yes Yes Yes Yes

Global Attributes

The


tag also supports the Global Attributes in HTML.


Event Attributes

The


tag also supports the Event Attributes in HTML.



More Examples

Example

Align a


element (with CSS):


Try it Yourself »

Example

A noshaded


(with CSS):


Try it Yourself »

Example

Set the height of a


element (with CSS):


Try it Yourself »

Example

Set the width of a


element (with CSS):


Try it Yourself »


HTML DOM reference: HR Object


Default CSS Settings

Most browsers will display the


element with the following default values:

Example

hr {
  display: block;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  margin-left: auto;
  margin-right: auto;
  border-style: inset;
  border-width: 1px;
}

Try it Yourself »


The


HTML element represents a thematic break between paragraph-level elements: for example, a change of scene in a story, or a shift of topic within a section.

Try it

Historically, this has been presented as a horizontal rule or line. While it may still be displayed as a horizontal rule in visual browsers, this element is now defined in semantic terms, rather than presentational terms, so if you wish to draw a horizontal line, you should do so using appropriate CSS.

Attributes

This element's attributes include the global attributes.

align Deprecated Non-standard

Sets the alignment of the rule on the page. If no value is specified, the default value is left.

color Non-standard Deprecated

Sets the color of the rule through color name or hexadecimal value.

noshade Deprecated Non-standard

Sets the rule to have no shading.

size Deprecated Non-standard

Sets the height, in pixels, of the rule.

width Deprecated Non-standard

Sets the length of the rule on the page through a pixel or percentage value.

Example

HTML

<p>
  This is the first paragraph of text.
  This is the first paragraph of text.
  This is the first paragraph of text.
  This is the first paragraph of text.
p>

<hr>

<p>
  This is the second paragraph of text.
  This is the second paragraph of text.
  This is the second paragraph of text.
  This is the second paragraph of text.
p>

Result

Specifications

Specification
HTML Standard
# the-hr-element

Browser compatibility

BCD tables only load in the browser

See also

Can you style hr in HTML?

Its simple to add a horizontal line in your markup, just add:
. Browsers draw a line across the entire width of the container, which can be the entire body or a child element. Originally the HR element was styled using attributes.

How do I change my HR tag?

Move
inside title element [

in this example].

Add padding-left:25% and padding-right:25% to title element..
Add text-align:center to title element..

How do I color a HR tag?

Attribute Values:.
color_name: It sets the Text color by using the color name. For example “red”..
hex_number: It sets the text color by using the color hex code. For example “#0000ff”..
rgb_number: It sets the text color by using the rgb code. For example: “RGB(0, 153, 0)”..

Can we change HR color in HTML?

You can simply use the CSS background-color property in combination with the height and border to the change the default color an
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.