LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-26-2006, 07:12 AM   #1
Hosiah
Member
 
Registered: Sep 2004
Location: Des Moines, Iowa
Distribution: Slackware, Mandriva, Debian derivatives, +BSD/ Solaris/ Minix/ plan9/ GNU/HURD...
Posts: 185

Rep: Reputation: 31
CSS/XHTML combined tags possible?


This is a question that so far all searching for has come up null.

To explain: I want to be able to declare a tag in a CSS stylesheet that would implement many HTML tags with one tag. For example: when I post ASCII art in my blog, I need the "code" tag so the renderer doesn't mistake errant symbols for commands, the "pre" tag so it doesn't change line-break formatting, and then I want cool green text on black background for that nostalgic terminal look, and finally turn off default floating on the div class. So if I could do this:

Code:
.ASCII_art
{
  apply: code;
  apply: pre;
  foreground-color: #00FF00;
  background-color: #000000;
  float: none;
}
I could just wrap one tag and be done with it, and also my commenters could do the same. Many other applications come to mind for this method. Generally, instead of specifying tags "foo, bar, and baz", I could just use a macro-tag "buzz" and declare in a stylesheet what buzz means.

Does such a concept exist in web design anywhere? What's the name of it, so I can Google for it?
 
Old 09-27-2006, 07:06 PM   #2
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
I don't think so. That would be against the 'separation of content and presentation' which is what CSS is all about. If you can create meta tags that enable this, I think it would be a function of your blog software, not the xhtml/css spec.

You could write a simple function that takes care of all this for you, ie: (assuming php here)

Code:
function showAscii($file) {
    print "<code class='ASCII_art'><pre>";
    $ascii = file_get_contents($file);
    print $ascii;
    print "</code></pre>";
}
And call like:

Code:
<?php showAscii("./ascii_dragon.txt"); ?>
etc...

Of course this will depend on if your blogging software is 'hackable'.

Last edited by bulliver; 09-27-2006 at 07:09 PM.
 
Old 09-27-2006, 10:03 PM   #3
95se
Member
 
Registered: Apr 2002
Location: Windsor, ON, CA
Distribution: Ubuntu
Posts: 740

Rep: Reputation: 32
I think it would be best if you explained a little more about your project, so we could give you some more creative ideas to solve your problem. Just so you know, the code tag won't let you write HTML, the characters still have to be escaped. I think your really just looking for the pre tag, styling that, then using some server side function to turn special characters into their XHTML entity equivalents. Example, php's htmlentities
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with XHTML/CSS rendering in IE vharishankar General 14 09-03-2006 05:07 AM
XHTML/CSS question: how to draw a curved box for a sidebar vharishankar General 5 08-04-2005 08:32 PM
After Editing Tags with JuK - XMMS do not display tags correctly Artik Linux - Software 0 07-23-2005 05:55 AM
Count combined filesize MiniMe001 Linux - Newbie 2 05-16-2005 09:48 AM
do you use xhtml ? linowes General 0 01-14-2003 11:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration