Jump to content

Using of <div> tag to a paragraph

sjcrox's Photo
Posted Nov 26 2012 11:51 PM
14658 Views

<div style="color: red">
<p>
Class A template that describes the kinds of state and behavior that objects of its type support
</P>
</div>

when i refresh the web browser this div tag was not work

thanks

Tags:
1 Subscribe


2 Replies

+ 1
  rachel.j's Photo
Posted Nov 29 2012 07:01 AM

Hi,

This markup is fine, and should work. What problem are you seeing? Is the color not being applied? The markup is also a little redundant, wrapping the paragraph in a div doesn't add anything, because both are block elements. You could apply the style to the paragraph itself, like this:

<p style="color: red;">
    Class A template that describes the kinds of state 
    and behavior that objects of its type support
</p>


Or you could use CSS to style the paragraph (you would put the style in the head of your document or you could use an external CSS file):

<style>
p {
    color: red;
}
</style>

<p>
    Class A template that describes the kinds of state 
    and behavior that objects of its type support
</p>


Or if you just want specific paragraphs to be red (maybe because they're a warning, or something), you could use a class, and apply the style to that class:

<style>
.warning {
    color: red;
}
</style>

<p class="warning">
    Class A template that describes the kinds of 
    state and behavior that objects of its type support
</p>


Hope that helps!

Rachel James
O'Reilly Media
0
  best seller's Photo
Posted Dec 26 2012 07:40 AM

always use id or class and then write css code on that specific id or class............ it is very easy and satisfy all browser and create no problem anytime, anywhere.....

Thanks

You can visit my blog....
http://www.bestselli...oksreviews.com/