Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-23-2011, 08:50 AM   PM User | #1
toplisek
Regular Coder

 
Join Date: May 2006
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
toplisek has a little shameless behaviour in the past
Question How to set paragraph with class inside DIV?

I have set <p> specification within DIV.
Issue is that I have to define separate specifications for <p> but as this is indiside DIV it will be priority general paragraph spec.

How to disable general spec. to use my specific class for paragraph and keep general for other?

Is only solution DIV defined p?
toplisek is offline   Reply With Quote
Old 02-23-2011, 09:00 AM   PM User | #2
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello toplisek,
If your div was id, for example, myDiv you could style the paragraph tag inside it with this line in your CSS - #myDiv p {styling}

See more about specificity here.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 02-23-2011, 09:24 AM   PM User | #3
toplisek
Regular Coder

 
Join Date: May 2006
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
toplisek has a little shameless behaviour in the past
I have
# myDIV
(
.products1 p()

)
/DIV

Div has general p and class has specific p
How to make separate that class with name like product1 and its p will work?

You see inside DIV is CLASS name. ID has priority over CLASS as CLASS is inside this DIV.
PHP Code:

#mydiv .products1 p { margin: 0; margin-bottom: 10px; text-align: left; } 
will this work or it will take general p form #mydiv? is this correct?


will work or it will take general DIV p?

Last edited by toplisek; 02-23-2011 at 09:33 AM..
toplisek is offline   Reply With Quote
Old 02-23-2011, 11:21 AM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,587
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
I don’t understand the pseudo code you posted. Can you give us your real HTML?
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 02-23-2011, 05:57 PM   PM User | #5
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Quote:
Originally Posted by toplisek View Post
will this work or it will take general p form #mydiv? is this correct?


will work or it will take general DIV p?
That bit of CSS #mydiv .products1 p { margin: 0; margin-bottom: 10px; text-align: left; } , will apply to any paragraph tag that is in a div with the class of product that is contained in #mydiv.
In otherwords, it's pretty specific.

See this example, just copy/paste the whole thing into a new .html document and view it in your browser -
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
#mydiv .products1 p {
	margin: 0;
	margin-bottom: 10px;
	text-align: left;
	color: #f00;
}
p {color: #00f;}
</style>
</head>
<body>
    <div id="mydiv">
        <div class="products1">
        	<p>some text targeted by #mydiv .products1 p</p>
        <!--end .products1--></div>
        	<p>some text with the sitewide p styling of blue.</p>
    <!--end mydiv--></div>
</body>
</html>
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

Last edited by Excavator; 02-23-2011 at 06:02 PM..
Excavator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 06:23 PM.


Advertisement
Log in to turn off these ads.