Reputation: 25842
I am processing various RSS news items.
In those items, some of them always have various white spaces (like tabs, redundant space, etc) in front within <p></p>
or <div></div>
.
How can I automatically remove those unnecessary white spaces in the beginning of a paragraph, using pure HTML or CSS?
Upvotes: 0
Views: 4340
Reputation: 776
I had same issue I solved it using "white space attribute"
example :
p{
white-space: normal;
}
Upvotes: 0
Reputation: 25493
you can use CSS for doing this:
div
{
white-space:nowrap;
}
or
p
{
white-space:nowrap;
}
Sequences of whitespace will collapse into a single whitespace. Text will never wrap to the next line. The text continues on the same line until a
tag is encountered
Hope this helps.
Upvotes: 1
Reputation: 3487
Unfortunately, you cannot process HTML element with HTML or CSS. You need a JS for this.
Upvotes: 0
Reputation: 175098
Not possible. HTML nor CSS are not programming languages, as such, they do not contain the tools to preform string manipulation.
You could do it easily with javascript like so:
var str = "This is a string with multiple spaces";
str = str.replace(/ {2,}/g, " ");
document.write("<pre>" + str + "</pre>");
Will print
This is a string with multiple spaces
Upvotes: 2
Reputation: 51694
If using jQuery, there's the jQuery.trim()
function
JavaScript doesn't provide a trim function but here's an example how to write it yourself.
Upvotes: 0