Add line to end of h tag with CSS or jQuery

jquery append
jquery append multiple elements
jquery append after
horizontal line before text css
horizontal line after text css
line under heading css
jquery add text to div
jquery prepend

You can try like below:

.titleContainer {
  animation:change 3s linear infinite alternate;
.titleLeft {
     /*the line placed at the bottom of the container*/
     linear-gradient(orange,orange) 0 calc(100% - 0.5em)/100% 2px no-repeat;
.titleLeft span {
  /*inherit the background-color and hide the line under the text*/
  padding:0 5px;

@keyframes change {
  to {max-width:100px }
<div class="titleContainer">
<h1 class="titleLeft"><span>how We turn your</span></h1>

<div class="titleContainer">
<h1 class="titleLeft" style="background-color:red;"><span>how We turn your</span></h1>

How to display a horizontal line before and after a heading in css , jquery html css How can I put the horizontal line only before and after the heading and also h1 { font-size: 4rem; } h1::before, h1::after { display: inline-​block; A pseduo-element will be your best bet here. You can change the width of the line to whatever you need it, but for this example I used 500px. Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java and XML.

If you know which word (or group of words) you want the line to be next to, you can wrap those words inside a span and use display: flex + ::after on the span to get the desired effect shown in your first image.

<h1>How we turn <span>your</span> business requirements into</h1>
  h1 span {
    width: 100%;
    background: black;
    display: flex;
    justify-content: space-between;
    align-items: center;

  h1 span:after {
    content: "";
    background: orange;
    border-radius: 4px;
    display: block;
    height: 6px;
    min-width: 50%;
    flex: 1;
    margin-left: 16px;

Here's a sandbox with a complete example.

If you just want it to take the remaining width of the title space, you shouldn't need to do any jQuery shenanigans with this approach.

JavaScript & jQuery: The Missing Manual, Add <script> tags and the $(document).ready() function, and then call the anythingSlider(); }); // end ready </script> There are many ways to customize the .css"> This line loads the anythingslider.css file, which contains specific styles for Locate the heading 1 tag—<h1>Anything Slider</h1>—in the code, and on the  HTML CSS JAVASCRIPT SQL PYTHON PHP BOOTSTRAP HOW TO W3.CSS JQUERY Mode Toggle Text Toggle Class Add Class Remove Class Active Class Tree a vertical line with CSS.

You could use an empty span with some styling to solve your issue. Try adding <span id='myLine'></span> after the h tag, with some CSS styling:

#myLine {
  width: 80%; /*or any percentage that makes it look good for you*/
  /*also set the border bottom to look the way you want, e.g.:*/
  border-bottom: 2px solid orange;

.append(), DOM element, text node, array of elements and text nodes, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. CSS Border Properties. The CSS border properties allow you to specify the style, width, and color of an element's border.

.appendTo(), Description: Insert every element in the set of matched elements to the end of the A selector, element, HTML string, array of elements, or jQuery object; the  Notice that with the DOM notation, quotation marks around the property names are optional, but with CSS notation they're required due to the hyphen in the name. When a number is passed as the value, jQuery will convert it to a string and add px to the end of that string.

HTML5, JavaScript, and jQuery 24-Hour Trainer, This will include adding a header, a footer, and an area for adding new The opening tag should be immediately before the opening table tag, while the closing tag Additionally, add a text-align property with a value of center, and a line-height LESSON 5 STRUCTURING PAGES WITH CSS Try It Lesson Requirements  The .append() method inserts the specified content as the last child of each element in the jQuery collection (To insert it as the first child, use .prepend()). The .append() and .appendTo() methods perform the same task. The major difference is in the syntax-specifically, in the placement of the content and target.

.insertAfter(), Description: Insert every element in the set of matched elements after the target. A selector, element, array of elements, HTML string, or jQuery object; the <h2​>Greetings</h2> but instead returned the original set which made it difficult to use the .end() Attributes · Callbacks Object · Core · CSS · Data · Deferred Object  To add a title in anchor tag in jQuery, use the prop() method. The prop() method is used to set properties and values of the selected elements. You can try to run the following code to learn how to add a title in anchor tag using jQuery − Example. Live Demo