Global and Local Declarations

Giganews Newsgroups
Subject: Global and Local Declarations
Posted by:  Mike Copeland (mrc23…@cox.net)
Date: Mon, 31 Jul 2017

I have a Web site that's composed of many pages; some are crosslinked
to others (not a fector in my problem here).  As I wish to have every
page rendered with specific aspects (font, font size, margins), I have
programmed a "body" statement in every page's code.
  However, although certain aspects of the code are common, others vary
(i.e. background image/color, font color, etc.).  In an attempt to
reduce maintenance issues, I tried to code the common features in my
global .CSS file, and adding a CSS selector in each code file for the
variable aspects.  It doesn't work...<sigh>
  Specifically, each page's code had a "body" statement (in the
"style" section) that looked like this:
  body { margin: 0 150px 0 150px; font: Verdana; font-size: 1.5em;
        color: white; background-image: url("bg-green-grass.jpg"); }
  The first line is the code common to all pages, and the "color" and
"background" vary.  I tried to make the 2nd part code-local (e.g.
  .opt { color: white; background-image: url("bg-green-grass.jpg"); }
and moved the 1st portion to my common .CSS file:
  .global    { margin: 0 150px 0 150px; font: Verdana; font-size:
1.5em; }
  Furthermore, I tried several CSS names (e.g. ".global, .body, body")
with no success.  Of course, I used the page code like this:
  <body class="global opt">
  <body class="body opt">
Also without success...
  Is there something about the "body tag" and its specification that
prohibits my doing this?  Am I missing some fundamental CSS/HTML rule
here?  Is there snother way to accomplish this sort of thing?  Please
advise.  TIA

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Replies