469,935 Members | 1,612 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,935 developers. It's quick & easy.

Styles for tags inside divs

Hopefully not a dumb question, but...

Say you have a <div id="blah"Is there a way to set the style for other
tags inside that specific div without having to set those tags with a
class? Meaning could I do a <pinside the div that would display set
style without having to do a <p class="blahblah"and then any <p>
outside that div would be displayed as normal or however I have defined <p>?

Thanks for your thoughts,
Patrick
May 11 '07 #1
6 1586
Patrick <ps****@marine.usf.eduwrites:
Say you have a <div id="blah"Is there a way to set the style for
other tags inside that specific div without having to set those tags
with a
class? Meaning could I do a <pinside the div that would display set
style without having to do a <p class="blahblah"and then any <p>
outside that div would be displayed as normal or however I have
defined <p>?
#blah p {
...
}

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
May 11 '07 #2
Patrick wrote:
Say you have a <div id="blah"Is there a way to set the style for
other tags inside that specific div without having to set those tags
with a class? Meaning could I do a <pinside the div that would
display set style without having to do a <p class="blahblah"and
then any <poutside that div would be displayed as normal or however
I have defined <p>?
#blah p { /* styles here */ }

Remember, you can only use an id once in a document.

--
-bts
-Motorcycles defy gravity; cars just suck
May 11 '07 #3
Beauregard T. Shagnasty wrote:
Patrick wrote:

>>Say you have a <div id="blah"Is there a way to set the style for
other tags inside that specific div without having to set those tags
with a class? Meaning could I do a <pinside the div that would
display set style without having to do a <p class="blahblah"and
then any <poutside that div would be displayed as normal or however
I have defined <p>?


#blah p { /* styles here */ }

Remember, you can only use an id once in a document.
Seems to work also if I do .blah p { /* styles here */ } Do you know how
much easier this just made things for me?

Patrick
May 11 '07 #4
Sherm Pendley wrote:
Patrick <ps****@marine.usf.eduwrites:

>>Say you have a <div id="blah"Is there a way to set the style for
other tags inside that specific div without having to set those tags
with a
class? Meaning could I do a <pinside the div that would display set
style without having to do a <p class="blahblah"and then any <p>
outside that div would be displayed as normal or however I have
defined <p>?


#blah p {
...
}

sherm--
Wow! That's it? I just take my div id name, #blah put the p there and
then define the style inside.

Thanks!
Patrick

May 11 '07 #5
..oO(Patrick)
>Hopefully not a dumb question, but...

Say you have a <div id="blah"Is there a way to set the style for other
tags inside that specific div without having to set those tags with a
class?
That's what descendant selectors are for.

5.5 Descendant selectors
http://www.w3.org/TR/CSS21/selector....dant-selectors
>Meaning could I do a <pinside the div that would display set
style without having to do a <p class="blahblah"and then any <p>
outside that div would be displayed as normal or however I have defined <p>?
p {color: green}
#blah p {color: red}

Micha
May 11 '07 #6
Patrick wrote:
Beauregard T. Shagnasty wrote:
>Patrick wrote:
>>Say you have a <div id="blah"Is there a way to set the style for
other tags inside that specific div without having <snip>

#blah p { /* styles here */ }

Remember, you can only use an id once in a document.

Seems to work also if I do .blah p { /* styles here */ }
#blah is for <div id="blah">
..blah is for <div class="blah">
Do you know how much easier this just made things for me?
It's the KISS principle.

--
-bts
-Motorcycles defy gravity; cars just suck
May 11 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by TheKeith | last post: by
9 posts views Thread by Chandy | last post: by
6 posts views Thread by Rich Sagall | last post: by
24 posts views Thread by Kourosh | last post: by
2 posts views Thread by Eero Tuomenoksa | last post: by
2 posts views Thread by viveklinux | last post: by
2 posts views Thread by bruce131 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.