473,396 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1633
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: TheKeith | last post by:
Isn't there a style for preformatted text, instead of having to use the pre tags? Help would be appreciated--thanks.
6
by: MNF | last post by:
Hi everyone, I am using document.getElementById function in JavaScript to find a control within an html body, but instead I get back META item, because incidently the name of one meta tags is the...
9
by: Chandy | last post by:
Hi, Is there any way to apply a style that will effectively block the application of any applied or inherited styles for that object and any contained objects? E.g., CSS: P {backgro...}
6
by: Rich Sagall | last post by:
I have a table with a number hot links. I want to define the text in the table. I also want the underlines to disappear from the links and to have the text change to red when the cursor is on the...
24
by: Kourosh | last post by:
I have a lot of DIV tags on an HTML page. I want to group some of them so that I can hide them all together at once if needed. What's a good way to do this? I want this to be compatible with at...
2
by: Eero Tuomenoksa | last post by:
Hi Does someone knows how i can show/hide multible divs at one click? -- Käytössä Operan vallankumouksellinen sähköpostiohjelma: http://www.opera.com/mail/
2
by: viveklinux | last post by:
Hi, Have a FAQ page , where have many sets of questions and answers. The questions need to be a different colour / style and the answers different. Was wondering is there a easy way to do this...
13
by: howa | last post by:
e.g. <div class="main"> <p>ssssss</p> <p>ssssss</p> <p>ssssss</p> <p>ssssss</p>
2
by: bruce131 | last post by:
Hi. I have the following XML .. <?xml-stylesheet type="text/xsl" href="try.xslt"?> <head> <title>Title</title> <desc> <p>Description<ul><li>item 1</li><li>item 2</li></ul></p> </desc>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.