Is it possible to insert a tab character in HTML instead of having to type
four times?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
If you're looking to just indent the first sentence in a paragraph, you could do that with a small CSS trick:
There really isn't any easy way to insert multiple spaces inside (or in the middle) of a paragraph. Those suggesting you use CSS are missing the point. You may not always be trying to indent a paragraph from a side but, in fact, trying to put extra spaces in a particular spot of it.
In essence, in this case, the spaces become the content and not the style. I don't know why so many people don't see that. I guess the rigidity with which they try to enforce the separation of style and content rule (HTML was designed to do both from the beginning - there is nothing wrong with occasionally defining style of an unique element using appropriate tags without having to spend a lot more time on creating CSS style sheets and there is absolutely nothing unreadable about it when it's used in moderation. There is also something to be said for being able to do something quickly.) translates to how they can only consider whitespace characters as being used only for style and indentation.
And when there is no graceful way to insert spaces without having to rely on
 
and
tags, I would argue that the resulting code becomes far more unreadible than if there was an appropriately named tag that would have allowed you to quickly insert a large number of spaces (or if, you know, spaces weren't needlessly consumed in the first place).As it is though, as was said above, your best bet would be to use
 
to insert in the correct place.It depends on which character set you want to use.
There's no tab entity defined in ISO-8859-1 HTML - but there are a couple of whitespace characters other than
such as 
, 
,and 
.In ASCII,
	
is a tab.Here is a complete listing of HTML entities and a useful discussion of whitespace on Wikipedia.
I have used a span with in line styling. I have had to do this as I as processing a string of plain text and need to replace the \t with 4 spaces (appx). I couldn't use
as further on in the process they were being interpreted so that the final mark up had non-content spaces.HTML:
I used it in a php function like this:
You can also use:
And replace "p" with any other selector you have in mind.
I use a list with no bullets to give the "tabbed" appearance. (It's what I sometimes do when using MS Word)
In the CSS file:
And in the HTML file use unordered lists:
The beauty of this solution is that you can make further indentations using nested lists.
A noob here talking, so if there are any errors, please comment.