Set CSS property equal to another CSS property?

Discussion in 'HTML' started by Noozer, Oct 13, 2004.

  1. Noozer

    Noozer Guest

    Is it possible to set one CSS propery equal to another?

    I have not set any font properties for the body of my page, so the user will
    see the browsers default font. When I use the <pre> tag to preserve the
    layout of some text the font applied is not the same.

    Is there a way to set the font used by the <pre> tag to be the default
    browser font (same as the body) if the font isn't know when the page is
    created?

    I assume that <pre> is using the default monospace font instead of the
    default proportional font. Any way to set the <pre> tag to use the
    proportional font?

    Thanks!
     
    Noozer, Oct 13, 2004
    #1
    1. Advertising

  2. Noozer

    Neal Guest

    On Wed, 13 Oct 2004 18:52:02 GMT, Noozer <> wrote:

    > Any way to set the <pre> tag to use the
    > proportional font?


    pre {font-family: serif;}

    This presumes the UA is using a serif font as the default, which I find to
    be normally the case. But you can get them to match using:

    body, pre {font-family: serif;}

    To address your other question - no, you can't tell the browser to use its
    default body font on pre instead of the default pre font.
     
    Neal, Oct 13, 2004
    #2
    1. Advertising

  3. Noozer

    Steve Pugh Guest

    On Wed, 13 Oct 2004 18:52:02 GMT, "Noozer" <> wrote:

    >Is it possible to set one CSS propery equal to another?


    No.

    >I have not set any font properties for the body of my page, so the user will
    >see the browsers default font. When I use the <pre> tag to preserve the
    >layout of some text the font applied is not the same.
    >
    >Is there a way to set the font used by the <pre> tag to be the default
    >browser font (same as the body) if the font isn't know when the page is
    >created?


    pre {font-family: inherit;}

    But doesn't work in all browsers.

    Steve
     
    Steve Pugh, Oct 13, 2004
    #3
  4. "Noozer" <> wrote:

    > Is it possible to set one CSS propery equal to another?


    Yes, e.g. left: 42px; right 42px; :) But what you meant to ask isn't
    possible in practice.

    > I have not set any font properties for the body of my page, so the
    > user will see the browsers default font. When I use the <pre> tag to
    > preserve the layout of some text the font applied is not the same.


    Indeed. The <pre> element is _meant_ to set the font to a monospace, and
    HTML specifications explicitly say that authors should not change this in
    a style sheet. You migh decide to take a more liberal view on this, but I
    think it's best to ask first what you are trying to achieve. "Preserve
    the layout" in which sense? URL?

    > Any way to set the <pre> tag to use the proportional font?


    Setting
    pre { font-family: Times New Roman, serif; }
    would probably be a good shot, since Times New Roman is the most common
    default font at least in factory settings.

    But it's better to avoid creating the problem in the first place. Avoid
    <pre>, especially if you don't want monospace font. Usually there's a
    better approach.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
     
    Jukka K. Korpela, Oct 13, 2004
    #4
  5. Noozer

    Neal Guest

    On Wed, 13 Oct 2004 19:36:11 +0000 (UTC), Jukka K. Korpela
    <> wrote:

    > The <pre> element is _meant_ to set the font to a monospace, and
    > HTML specifications explicitly say that authors should not change this in
    > a style sheet.


    "Authors are discouraged from altering this behavior through style sheets."

    Not quite as strongly worded as "should not" would imply. The absence of
    "should not" implies to me the discouragement is less important than if
    they said "should not" but is still not quite "may".

    I think if one has a good purpose to override the monospace, you shouldn't
    choose not to do it based on the spec. Obviously willy-nilly abandonment
    of monospace might hurt usability in some cases.
     
    Neal, Oct 13, 2004
    #5
  6. Noozer

    Neal Guest

    On Wed, 13 Oct 2004 15:48:33 -0400, Neal <> wrote:

    > On Wed, 13 Oct 2004 19:36:11 +0000 (UTC), Jukka K. Korpela
    > <> wrote:
    >
    >> The <pre> element is _meant_ to set the font to a monospace,


    Left one other point out. The spec reads,

    "... When handling preformatted text, visual user agents:
    ....
    * May render text with a fixed-pitch font.
    ...."

    The use of a fixed-pitch font is clearly optional for UAs, not required.
     
    Neal, Oct 13, 2004
    #6
  7. Noozer

    Noozer Guest

    "Jukka K. Korpela" <> wrote in message
    news:Xns9581E5CEEC26Fjkorpelacstutfi@193.229.0.31...
    > "Noozer" <> wrote:
    >
    > > Is it possible to set one CSS propery equal to another?

    >
    > Yes, e.g. left: 42px; right 42px; :) But what you meant to ask isn't
    > possible in practice.
    >
    > > I have not set any font properties for the body of my page, so the
    > > user will see the browsers default font. When I use the <pre> tag to
    > > preserve the layout of some text the font applied is not the same.

    >
    > Indeed. The <pre> element is _meant_ to set the font to a monospace, and
    > HTML specifications explicitly say that authors should not change this in
    > a style sheet. You migh decide to take a more liberal view on this, but I
    > think it's best to ask first what you are trying to achieve. "Preserve
    > the layout" in which sense? URL?


    My page is generated by ASP. One section is multiple lines of text and I
    want to preserve the line breaks. Wrapping of the longer lines is not
    important as long as the break at the end of the line remains.

    If I use the following...

    <p>This is one line.
    This is another line. This line is very long and might be wider than the
    browser window.
    This is the last line</p>

    ....I don't want...
    This is one line.This is another line. This line is very long and might be
    wider than the browser window. This is the last line

    ....This would be acceptable:

    This is one line.
    This is another line. This line is very long and might be wider than the
    browser window.
    This is the last line

    ...as would this:

    This is one line.
    This is another line. This line is very long and might be
    wider than the browser window.
    This is the last line

    Using the white-space: CSS property does not work in my case, so I am trying
    to use <PRE>, which does preserve the breaks, but changes the font.
     
    Noozer, Oct 13, 2004
    #7
  8. Noozer

    Neal Guest

    On Wed, 13 Oct 2004 20:06:10 GMT, Noozer <> wrote:

    > My page is generated by ASP. One section is multiple lines of text and I
    > want to preserve the line breaks. Wrapping of the longer lines is not
    > important as long as the break at the end of the line remains.


    Can you not get the ASP to add <BR> at the carriage returns? I'm not
    versed in ASP, so excuse me if this is incredibly stupid.
     
    Neal, Oct 13, 2004
    #8
  9. "Noozer" <> wrote:

    > One section is multiple lines of text and I
    > want to preserve the line breaks. Wrapping of the longer lines is not
    > important as long as the break at the end of the line remains.


    But why? What is the meaning of the breaks? Although you could force line
    breaks with <br>, solving the problem in a sense (no <pre> needed), it's
    best to consider first some other options. But this really depends on the
    material and on the question _why_ you wish to break lines, i.e. what the
    intended message is.

    For one thing, line breaks as such (whether generated with <br> or <pre>
    or otherwise) are insignificant (or, more exactly, equivalent to spaces)
    in non-visual rendering. So is the intended message something that you
    could say in a different way, a way that works as universally as
    possible?

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
     
    Jukka K. Korpela, Oct 13, 2004
    #9
  10. Noozer

    Adrienne Guest

    Gazing into my crystal ball I observed "Noozer" <>
    writing in news:SUfbd.733766$gE.723285@pd7tw3no:

    >> Indeed. The <pre> element is _meant_ to set the font to a monospace,
    >> and HTML specifications explicitly say that authors should not change
    >> this in a style sheet. You migh decide to take a more liberal view on
    >> this, but I think it's best to ask first what you are trying to
    >> achieve. "Preserve the layout" in which sense? URL?

    >
    > My page is generated by ASP. One section is multiple lines of text and
    > I want to preserve the line breaks. Wrapping of the longer lines is not
    > important as long as the break at the end of the line remains.
    >
    >


    Then what you want to do is this:

    <%
    textbreak = replace(variable,vbcrlf,"<br>")
    %>
    <p><%=textbreak%></p>

    --
    Adrienne Boswell
    Please respond to the group so others can share
     
    Adrienne, Oct 13, 2004
    #10
  11. Noozer

    Mitja Guest

    Neal wrote:
    > On Wed, 13 Oct 2004 20:06:10 GMT, Noozer
    > <> wrote:
    >
    >> My page is generated by ASP. One section is multiple
    >> lines of text and I want to preserve the line breaks.
    >> Wrapping of the longer lines is not important as long as
    >> the break at the end of the line remains.

    >
    > Can you not get the ASP to add <BR> at the carriage
    > returns? I'm not versed in ASP, so excuse me if this is
    > incredibly stupid.


    Neither am I, but it should be dead easy. And, indeed, after two google searches: instead of using Response.write("blah"), use
    Response.write(Replace("blah",Environment.NewLine,"<br>")). Untested.
     
    Mitja, Oct 13, 2004
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joshua Beall
    Replies:
    1
    Views:
    473
    Bertilo Wennergren
    Dec 10, 2003
  2. Paul F. Johnson
    Replies:
    12
    Views:
    694
    Mark Parnell
    Oct 25, 2004
  3. Noozer
    Replies:
    3
    Views:
    1,839
    Andy Dingley
    Apr 19, 2006
  4. Rob
    Replies:
    3
    Views:
    334
    Joe Greer
    Apr 23, 2008
  5. Mangler

    Set multiple fields equal to one value

    Mangler, Nov 13, 2006, in forum: ASP General
    Replies:
    1
    Views:
    112
    Bob Barrows [MVP]
    Nov 13, 2006
Loading...

Share This Page