473,761 Members | 9,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stylesheet with several <pre> styles?

How do I set several different properties for PRE in
a CSS stylesheet, rather than resorting to this:

<BODY>

<PRE STYLE="font-family:monospac e;
font-size:0.95em;
width:40%;
border:red 2px solid;
color:red;
background-color:#FBB; ">
This is red
</PRE>

<PRE STYLE="font-family:monospac e;
font-size:0.95em;
width: 40%;
border:blue 2px solid;
color:blue;
background-color:#BBF; ">
This is blue
</PRE>

<PRE STYLE="font-family:monospac e;
font-size:0.95em;
width: 40%;
border:green 2px solid;
color:green;
background-color:#BFB; ">
This is green
</PRE>

</BODY>

(the above is just an example)

Regards,
Alan
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Jul 20 '05 #1
7 18534
Alan Illeman wrote:
How do I set several different properties for PRE in
a CSS stylesheet, rather than resorting to this:

<BODY>

<PRE STYLE="font-family:monospac e;
font-size:0.95em;
width:40%;
border:red 2px solid;
color:red;
background-color:#FBB; ">
This is red
</PRE>

<PRE STYLE="font-family:monospac e;
font-size:0.95em;
width: 40%;
border:blue 2px solid;
color:blue;
background-color:#BBF; ">
This is blue
</PRE>

<PRE STYLE="font-family:monospac e;
font-size:0.95em;
width: 40%;
border:green 2px solid;
color:green;
background-color:#BFB; ">
This is green
</PRE>

</BODY>

(the above is just an example)

Regards,
Alan
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


Would this do?

In CSS:
..pre1 {font-family:monospac e;
font-size:0.95em;
width:40%;
border:red 2px solid;
color:red;
background-color:#FBB;}

And so on.

In Body
<pre class="pre1">Th is is red</pre>

--
Arne
http://w1.978.telia.com/~u97802964/
Jul 20 '05 #2
"Alan Illeman" <il******@surfb est.net> wrote:
How do I set several different properties for PRE in
a CSS stylesheet, rather than resorting to this:

<PRE STYLE="font-family:monospac e;
font-size:0.95em;
width:40%;
border:red 2px solid;
color:red;
background-color:#FBB; ">
This is red
</PRE>

<PRE STYLE="font-family:monospac e;
font-size:0.95em;
width: 40%;
border:blue 2px solid;
color:blue;
background-color:#BBF; ">
This is blue
</PRE>

<PRE STYLE="font-family:monospac e;
font-size:0.95em;
width: 40%;
border:green 2px solid;
color:green;
background-color:#BFB; ">
This is green
</PRE>


Specifying monospace is superfluous as it's the default for <pre>,
specifying 0.95em may also be pointless.

pre.special{wid th:40%}
pre.special.one {border:2px solid red;color:red;b ackground:blue}
pre.special.two {border:2px solid green;color:gre en;background:r ed}
pre.special.thr ee{border:2px solid blue;color:blue ;background:gre en}

Replace the "special, one, two, three" class names with something
meaningful.

<pre class="special one">foobar</pre>
<pre class="special two">foobar</pre>
<pre class="special three">foobar</pre>

--
Spartanicus
Jul 20 '05 #3
On Sun, 8 Aug 2004 07:33:33 -0400, Alan Illeman wrote:
How do I set several different properties for PRE in
a CSS stylesheet, rather than resorting to this:
Several ways, the easiest is if there are no other
<PRE> sections..

<head>
....
<style type='text/css'>
pre {
// this is a default for <PRE> sections AFAIU, redundant..
// font-family:monospac e;
font-size:0.95em;
width:40%;
// AFAIR, you can override *just* the color, see below..
border:black 2px solid;
}
</style>
</head>
<BODY>
<PRE STYLE="border-color:red; color:red;
background-color:#FBB; ">
This is red
</PRE>
etc..

[ ..And why are you presuming you can manually space
text so that it fits 40% of the width of the page?
(If that is what the spaces are for) ]
(the above is just an example)


...hmmm. I always get suspicious when people pose
arbitrary examples that they think demonstrate the
problem/challenge they face. An *actual* page with
a 'real World(WideWeb)' example is generally better.

For further information see..
<http://www.spartanicus .utvinternet.ie/help_us_help_yo u.htm>
...or my own variant more geared to Java/Javascript
<http://www.physci.org/codes/sscce.jsp>

HTH

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 20 '05 #4

"Alan Illeman" <il******@surfb est.net> wrote in message
news:10******** *****@news.supe rnews.com...
How do I set several different properties for PRE in
a CSS stylesheet, rather than resorting to this:

<BODY>

<PRE STYLE="font-family:monospac e;

[snip]

Thank you Arne.
Thank you Spartanicus
I prefer your solution
Thank you Andrew Thompson
It's hard to provide a webpage, when I don't have a solution!

Alan


Jul 20 '05 #5
Spartanicus wrote on 08 aug 2004 in
comp.infosystem s.www.authoring.stylesheets:
Specifying monospace is superfluous as it's the default for <pre>,
specifying 0.95em may also be pointless.

pre.special{wid th:40%}
pre.special.one {border:2px solid red;color:red;b ackground:blue}
pre.special.two {border:2px solid green;color:gre en;background:r ed}
pre.special.thr ee{border:2px solid blue;color:blue ;background:gre en}

Replace the "special, one, two, three" class names with something
meaningful.

<pre class="special one">foobar</pre>
<pre class="special two">foobar</pre>
<pre class="special three">foobar</pre>


should be:

pre.special{wid th:40%}
pre.one{border: 2px solid red;color:red;b ackground:blue}
pre.two{border: 2px solid green;color:gre en;background:r ed}
pre.three{borde r:2px solid blue;color:blue ;background:gre en}

IMHO.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #6
"Evertjan." <ex************ **@interxnl.net > wrote:
pre.special{wid th:40%}
pre.special.one {border:2px solid red;color:red;b ackground:blue}
pre.special.two {border:2px solid green;color:gre en;background:r ed}
pre.special.thr ee{border:2px solid blue;color:blue ;background:gre en}


should be:

pre.special{wi dth:40%}
pre.one{border :2px solid red;color:red;b ackground:blue}
pre.two{border :2px solid green;color:gre en;background:r ed}
pre.three{bord er:2px solid blue;color:blue ;background:gre en}


There's no "should" about it, either method can be used.

--
Spartanicus
Jul 20 '05 #7

"Alan Illeman" <il******@surfb est.net> wrote in message
news:10******** *****@news.supe rnews.com...

"Alan Illeman" <il******@surfb est.net> wrote in message
news:10******** *****@news.supe rnews.com...
How do I set several different properties for PRE in
a CSS stylesheet, rather than resorting to this:

<BODY>

<PRE STYLE="font-family:monospac e;

[snip]

Thank you Arne.
Thank you Spartanicus
I prefer your solution
Thank you Andrew Thompson
It's hard to provide a webpage, when I don't have a solution!

Alan


Both methods
http://surfbest.net/~il******@surfbe...t-css/pre.html

Regards,
Alan
Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
10222
by: Headless | last post by:
I've marked up song lyrics with the <pre> tag because it seems the most appropriate type of markup for the type of data. This results in inefficient use of horizontal space due to UA's default rendering of <pre> in a fixed width font. To change that I'd have to specify a proportional font family, thereby falling into the size pitfall that is associated with any sort of author specified font family: a) If I specify a sans serif font...
2
2789
by: Buck Turgidson | last post by:
I want to have a css with 2 PRE styles, one bold with large font, and another non-bold and smaller font. I am new to CSS (and not exactly an expert in HTML, for that matter). Is there a way to do this in CSS? <STYLE TYPE="text/css"> pre{ font-size:xx-large;
3
12923
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will preserve formatting (white space and line feeds). However, this is not true when doing the same with the <code> tag listing (it will all be pasted on one line with multiple successive spaces treated as a single space) despite the fact that...
18
2267
by: John | last post by:
I'm getting ready to revamp my Magic Squares pages, which currently show the magic squares in this form: +---+---+---+---+---+---+---+---+---+---+---+ | 68| 81| 94|107|120| 1 | 14| 27| 40| 53| 66| +---+---+---+---+---+---+---+---+---+---+---+ | 80| 93|106|119| 11| 13| 26| 39| 52| 65| 67| +---+---+---+---+---+---+---+---+---+---+---+ | 92|105|118| 10| 12| 25| 38| 51| 64| 77| 79| +---+---+---+---+---+---+---+---+---+---+---+
7
2749
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no tags will remain making the page safe (I have to convert the linefeeds to <BR>s because the Server.EncodeHTML does not do that it seems). The problem is that users can use a special tag when editing the top to specify an area of the tip that will...
9
5548
by: Eric Lindsay | last post by:
I can't figure how to best display little snippets of shell script using <pre>. I just got around to organising to bulk validate some of my web pages, and one of the problems occurs with Bash shell pieces like this: <pre><code> #!/bin/sh ftp -i -n ftp.server.com&lt; &lt;EOF user username password epsv4 cd /
14
3632
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good readibility on browsers w/o css-support. For important notes, warnings etc I use the <pre> tag, which shows in a neat bordered box when viewed with css, and depending on its class a clarifying background-image is shown. I would like the...
0
9531
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8780
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.