Looking for something like a C-style macro

This is a discussion on "Looking for something like a C-style macro" within the Web Page Design section. This forum, and the thread "Looking for something like a C-style macro are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 19th, 2006, 03:31
New Member
Join Date: Aug 2006
Location: Troy
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Looking for something like a C-style macro

Hi, I just started using CSS. I would like to experiment with colors and fonts, so I'm looking for an easy way to make global changes.

I'd like to be able to define several colors and several fonts the way you do #define macros in C - you know #define UPPER 500 #define LOWER 0 -

Is there a way to make say,

color1 (gets) #330000, color2 (gets) #6699aa etc

so that I can put color1 in all the properties i want to have that color, and just change the color where it is defined. (I'd also like to be able to do this for fonts, family & size.)

thank you
LN
Reply With Quote

  #2 (permalink)  
Old Aug 19th, 2006, 03:59
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Looking for something like a C-style macro

http://www.w3schools.com/css/css_intro.asp
Reply With Quote
  #3 (permalink)  
Old Aug 19th, 2006, 04:26
New Member
Join Date: Aug 2006
Location: Troy
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Looking for something like a C-style macro

Hi, thanks for that link. This was one of the tutorials I used, but I didn't see anything that seemed to me to fit the description of what I was looking for.

I thought that the id Selector was close, but it didn't seem to be saying "this works like a macro" & it didn't say how I should use it. Is this what you were pointing me to? Do you have any additional information on how to use this?

thanks
Reply With Quote
  #4 (permalink)  
Old Aug 19th, 2006, 17:26
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Looking for something like a C-style macro

Forget the macro concept. There is no such thing but CSS does exactly want you want it to do when you know how to use it.

Basic styling options:
1. Styling tags, e.g.
Code: Select all
p {
   font-size: 12px;
   color: #FF0000;
}
This will set all text in any <p></p> tags to be 12px in height and coloured red.

2. Class styles, e.g.
Code: Select all
.blue14 {
   font-size: 14px;
   color: #0000FF;
}
NOTE the dot at the front of the class name. This is what defines it as a class.
With this, in any tag in your code you can add the class and that style will be applied, e.g.
Code: Select all
<div class='blue14'>...</div>
3. Id style, e.g.
Code: Select all
#thistagonly {
   font-weight: bold;
   font-style: italic;
}
This style can only be used once on any given page, e.g.
Code: Select all
<span id='thistagonly'>...</span>
The other thing to remember is that, as the name implies, styles cascade. That means they are given an order of precedence. Meaning that if the same attribute is defined in more than one style definition, then the style with the highest precedence applies. That order of precedence is as the numbers above.

But of course you wouldn't expect it to be that simple would you?

There is also the rule of specificity. This means that the more specific you make a definition, the greater precedence it will have where definitions clash. E.g.
Code: Select all
p {
   font-size: 12px;
   color: #FF0000;
}

p#larger {
   font-size: 14px;
}
The effect of these two is that the content of all <p> tags will be 12px high and red in colour, UNLESS one of those p tags has the the id='larger' in which case the content of that specific p tag will still be red but it will be 14px high.

Hope this helps you to understand.




Last edited by ukgeoff; Aug 19th, 2006 at 17:29.
Reply With Quote
Reply

Tags
cstyle, macro

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
My navigation style TheSealPortalTeam Graphics and 3D 12 Jan 23rd, 2008 17:30
style MetallicWarfare Starting Out 12 Aug 13th, 2007 09:00
web style littlebilly Website Planning 7 Jul 22nd, 2007 14:58
How to tell IE7 to use a pariticular style in a single style sheet figo2476 Web Page Design 5 May 25th, 2007 14:23
Just for style? timmytots Web Page Design 4 Nov 17th, 2005 21:01


All times are GMT. The time now is 09:05.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43