Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8524769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:46:56+00:00 2026-06-11T07:46:56+00:00

I have a span element with some text in it. I want the text

  • 0

I have a span element with some text in it.
I want the text to have a solid background color as well as start/end each line with the same amount of padding.

This jsfiddle shows the problem:
http://jsfiddle.net/VwsQg/

I found this very similar question: Add padding at the beginning and end of each line of text, but i need some space between each line as well.

This image illustrates the result I’m trying to accomplish:

enter image description here

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:46:57+00:00Added an answer on June 11, 2026 at 7:46 am

    This can be done without using JavaScript or an extra element for each line.

    HTML

    <span class="marker"><span class="marker"><span class="marker">
        consectetur adipiscing elit. Nam at sem eu ligula porttitor iaculis volutpat
        non lacus.
    </span></span></span>
    

    CSS

    .marker {
        background: #f77;
        padding: 3px 0;
        position: relative;
        left: -10px;
        line-height: 30px;
    }
    
    .marker .marker { left: 20px; }
    
    .marker .marker .marker { left: -10px; }
    

    See how it works on fiddle 3tP8m.

    Note: An ancestor of .marker element should have proper padding to contain this element correctly.

    All credits of this technic goes to Artem Polikarpov. See his original advice: “How to mark up the text on flexible bottom layer” (in Russian).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an element that contains two span tags that each contain some text.
I have some text in an element in my page, and i want to
I have my span tag: <span style=text-decoration:line-through > Hello World <a href=http://www.yahoo.com>Yahoo</a> </span> As
I within my li element I have a link and some text contained within
I have HTML which looks something like this: <span id=text> <span class=segment id=first>some text</span>
I have a horizontal navigation bar. Each button is a span with a background
I have a problem with selecting the correct element using the .delegate method. <div><span>Some
I have the following markup as a base: <div> <span>some dynamic text</span> <input type=text
I have some HTML: <div align=center style=border:1px solid red> This is some text in
Say I have the following HTML: <div> <span>span text</span> div text <span>some more text</span>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.