<div> and <span> question
Hi,
How can I use the id selector in a web page using and ?
Also,
How would you use grouped selectors and class to make all tags green but only green and italic?
Any help will be appresiated!
Hi,
How can I use the id selector in a web page using and ?
Also,
How would you use grouped selectors and class to make all tags green but only green and italic?
Any help will be appresiated!
greg posted this at 20:52 — 22nd October 2007.
He has: 1,581 posts
Joined: Nov 2005
With most things the way you call CSS style is usually the same, whether class or id.
so for div
the general rule is to use id for things you will only use once per page (same thing multiple pages is fine) class is really for styles you might use several times throughout a page
like text for example, you are usually better using a class for text as you tend to use that same text styling more than once per page
an id in css styling is labelled using a #
so
#id_name {
some css styling
}
stuff in the div
and class simply uses a dot
.class_name {
some css styling
}
stuff in the div
for the h1 h2
you can create all h1 styles with this:
h1{
font: bold 120% Arial,sans-serif;
color: #000000;
}
the above style will work whenever you use
change the colour to the green you want and the font styling to whatever you want
and of course add more things in there, like margins/padding
if you wanted a 20px gap under each h1 heading you can do that. margins will be best for blank spacing around a heading
so do the same for h2 and change the styling to whatever you want h2 to have
if both your h1 and h2 are to be the same except italic, you could just make the h1 without itallic
and wherever you use the h1 you can wrap the text in
eg
header will be green AND italic
but if you want to use the itallic header more than once you are better of making a second header h2 with italic
webwiz posted this at 00:20 — 23rd October 2007.
He has: 629 posts
Joined: May 2007
You can use the id attribute on (almost) any tag. Use a specific ID only once per page, though, as Greg points out.
You don't need a class to make headings green. This will do what you ask:
h1, h2 {color: green;}
h2 {font-style: italic;}
Cordially, David
--
delete from internet where user_agent="MSIE" and version < 8;
JennyScoth0109 posted this at 07:29 — 31st October 2007.
They have: 29 posts
Joined: Oct 2007
id selector
#id
{
/*your declaration here */
}
then in your div
<div id='id'>
<!-- rest of the code -->
</div>
for font color purposes
h1, h2
{
color:rgb(0,200,0);
}
h2
{
font-style:oblique;
}
Ontario Mortgage
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.