Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How to indent multiple lines

Posted on 2006-04-27
Medium Priority
Last Modified: 2010-05-18
Is there a way via CSS to indent the table cell contents for multple lines. Using text-indent, padding-left, margin-left only indent the first line and as it wraps, it begins the new line at the extreme left - no padding.
Question by:Bl248
  • 2
  • 2
LVL 14

Expert Comment

ID: 16557564
<p style="margin-left:20px;">This text will indent 20px, even wrapped lines. Try it, you'll like it.</p>

margins & padding will apply to every wrapped line in a <p> (they apply to the paragraph as a whole), but not in a <span>

to apply to an entire table cell and everything inside of it, you can use <td style="padding-left:20px;">

Author Comment

ID: 16557636
Thanks but I was looking for just a css style that could do this. I felt that I would need to change the HTML as well - and have a fix in place now. It would have been cleaner if I could have just used a CSS style as the template is used multiple times and I only wanted to change the CSS dynamically.
LVL 14

Accepted Solution

nltech earned 1000 total points
ID: 16558251
ya. sorry.  in order for indents to be selective, changes to the code would be needed, as you need a way to specify what particular elements to indent.  

be simple if you wanted every <p> indented,  td p {margin-left:20px;}

but to indent the 1st and 3rd <p>'s in table 1, row 2, column 2, and the 2nd <img> in table 2, row 1, column 3,  while leaving everything else alone.. would require some changes to the code for those elements.

Author Comment

ID: 16558594
Thanks for confirming :)

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question