Grabeorama Posted October 26, 2010 Share Posted October 26, 2010 Is there a way of defining the width of a tab in CSS?I'm using <xmp></xmp> tags to display some HTML code on my site, but the tabs are about 8 spaces wide. Is there a way of lowering that to 4 spaces? Link to comment Share on other sites More sharing options...
jeffman Posted October 26, 2010 Share Posted October 26, 2010 Nope. Note that the xmp tag is deprecated in HTML5. But using the pre tag won't solve the problem either.Here's an alternative. Use a div or p tag, and in CSS style it like this: div.pre { white-space: pre-wrap;} I just discovered that trick a couple days ago, and it solved a really nagging problem I was having with formatted text in a table cell. Link to comment Share on other sites More sharing options...
Grabeorama Posted October 26, 2010 Author Share Posted October 26, 2010 Ok thanks, but how would I keep the non-parsing of HTML code in <pre> tags? Link to comment Share on other sites More sharing options...
jeffman Posted October 26, 2010 Share Posted October 26, 2010 1. I'm not recommending <pre> tags2. I don't understand the rest of the question. Link to comment Share on other sites More sharing options...
Grabeorama Posted October 26, 2010 Author Share Posted October 26, 2010 Basically all I wanted was a method to display HTML code on a site, without it being interpreted as HTML or without using the "<" code. So I used the <xmp> tags. The only problem was the tabs were much too wide, and looked a little stupid so I wanted to decrease their size in CSS, but I don't think it's possible.Is there any other way of doing this? Link to comment Share on other sites More sharing options...
jeffman Posted October 26, 2010 Share Posted October 26, 2010 Oh, I see now. Well, <pre> tags are now recommended over the <xmp>, but I don't think you can control the way tabs are formatted, and changing the tag to pre won't make a difference. I agree it's annoying.Maybe you want to look into a server-side library that reformats things designated as code so they look like code. I have such a plugin on my wordpress site, and it looks great, but of course it's for wordpress. I can't imagine there's nothing similar for ordinary pages. Link to comment Share on other sites More sharing options...
Grabeorama Posted October 26, 2010 Author Share Posted October 26, 2010 Hmm, yeah I was trying to avoid complicating it too much with server side libraries. I like to have coded everything myself so if something goes wrong I have a much better chance of fixing it. I'll look into it though, there's surely a few PHP libraries out there that do what I'm looking for. Thanks for the help Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.