Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
Anybody know how to create label for code snippet block? I want that code block (<pre>) have label attached (say the filename) on the left and it should be on the same level as the "Collapse" text on the right, and also it should be the same small size. There is "title" attribute on &lt;pre&gt; tag but it is ignored by colourizer. I remember that I saw such formatting on CP some time ago but now I can't find any article that have such label layout. Any help? :((
Posted

1 solution

You might have to tweak the HTML. For example, I was able to achieve something like what you want (not exactly though):


Test:
int x = 5;


Using this code:


HTML
<br />
Test: <pre lang="text" style="width: 70%; float: right; display: inline;">int x = 5;</pre>
<div style="clear: left;"></div>

I'm not a CSS guru, so some of that is probably weird, but you get the idea. I'm not sure there is a way that CP facilitates that allows you to give a code block a title/header, so you may have to hack it yourself. You could also ask in the article writing forum. And if the functionality doesn't exist, you could ask in the site bugs/suggestion forum.
 
Share this answer
 
Comments
AspDotNetDev 19-Sep-10 0:00am    
Dang, the code looked different in the preview than when it posted. Oh well.
Yevhen Bobrov 19-Sep-10 5:29am    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900