473,499 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why does paragraph display weirdly inside div

Markus
6,050 Recognized Expert Expert
I'm a new designer and pretty young - 16.
I've recently encountered a problem with the paragraph tag inside a div.
I have a div within a div (both with id selectors) when i place a paragraph tag within the second div the line moves into a different posistion. Without the p tag the text is displayed properly.
Please help, it would be much appreciated.
Expand|Select|Wrap|Line Numbers
  1. <body bgcolor="#999999">
  2. <div id="content">
  3. <div id="content-top-bar"><p>This text appears a line down as to where you would expect it to be.<p/></div>
  4. </div>
  5. </body>
  6. body{
  7. background-color: #999999;
  8. margin: 0;
  9. padding: 0;
  10. }
  11.  
  12. #content{
  13. background-color: #ffffff;
  14. margin: 0 15% 0 15%;
  15. height: 600px;
  16. padding: 4px;
  17. }
  18.  
  19. #content-top-bar{
  20. background-color: #ffffff;
  21. height: 40px;
  22. border-width: 2px 2px 6px 2px;
  23. border-style: solid;
  24. border-color: #999999;
  25. }
  26.  
  27.  
Jun 24 '07 #1
8 5118
Markus
6,050 Recognized Expert Expert
It happens with any tag i use inside the div. :( This is so annoying. I've searched for hours and it's such a small script. I feel like such a damn failure, i've got no chance if i can't even suss this out. >=[

here's the example
Jun 24 '07 #2
drhowarddrfine
7,435 Recognized Expert Expert
You need to be more specific. What line? Which tags? Also, you declare Xhtml but some of your markup does not exist in Xhtml and is incorrect in html.
Jun 24 '07 #3
nathj
938 Recognized Expert Contributor
I'm a new designer and pretty young - 16.
I've recently encountered a problem with the paragraph tag inside a div.
I have a div within a div (both with id selectors) when i place a paragraph tag within the second div the line moves into a different posistion. Without the p tag the text is displayed properly.
Please help, it would be much appreciated.
Expand|Select|Wrap|Line Numbers
  1. <body bgcolor="#999999">
  2. <div id="content">
  3. <div id="content-top-bar"><p>This text appears a line down as to where you would expect it to be.<p/></div>
  4. </div>
  5. </body>
  6. body{
  7. background-color: #999999;
  8. margin: 0;
  9. padding: 0;
  10. }
  11.  
  12. #content{
  13. background-color: #ffffff;
  14. margin: 0 15% 0 15%;
  15. height: 600px;
  16. padding: 4px;
  17. }
  18.  
  19. #content-top-bar{
  20. background-color: #ffffff;
  21. height: 40px;
  22. border-width: 2px 2px 6px 2px;
  23. border-style: solid;
  24. border-color: #999999;
  25. }
  26.  
  27.  
One possible option is to set up a specific p class in the css that sets the padding and margins exactly as you want them.

Also try setting the position of the nested div to relative. I've had similar issues myself recently and this sorted me out. Unfortunately my development is currently all local so I can't show you that.

Finally, playing around with this stuff is often the name of the game, you are not a failure - be more positive.

Cheers
Nathan
Jun 25 '07 #4
Markus
6,050 Recognized Expert Expert
One possible option is to set up a specific p class in the css that sets the padding and margins exactly as you want them.

Also try setting the position of the nested div to relative. I've had similar issues myself recently and this sorted me out. Unfortunately my development is currently all local so I can't show you that.

Finally, playing around with this stuff is often the name of the game, you are not a failure - be more positive.

Cheers
Nathan
I tried the posistion: relative but nothing changed. I also changed the declaration to html - nothing happened. It looks as though there's something pushing the text down from the top andalso it isn't even being contained inside the div. It's just floats past it exceeding the div. - This was because of the height: 30px;
I've tried and tried all i can think of - which, in all honesty, isn't much.

- it's giving a blank line-break before and after the actual tag. This happens with most tags and all the line breaks are relative to the size of the text.

Could this be something to do with block elements?

Where can i find the CSS HTML God?

<3
Jun 25 '07 #5
Markus
6,050 Recognized Expert Expert
You need to be more specific. What line? Which tags? Also, you declare Xhtml but some of your markup does not exist in Xhtml and is incorrect in html.

Line 3, sorry. I changed the declaration to no avail. I'll just keep trying with it, somethings got to give, right?

<3
Jun 25 '07 #6
Markus
6,050 Recognized Expert Expert
Ok, it appears it's only in Opera. Sorry.

Opera is no-longer my favourite browser.

<3
Jun 25 '07 #7
nathj
938 Recognized Expert Contributor
I'm a new designer and pretty young - 16.
I've recently encountered a problem with the paragraph tag inside a div.
I have a div within a div (both with id selectors) when i place a paragraph tag within the second div the line moves into a different posistion. Without the p tag the text is displayed properly.
Please help, it would be much appreciated.
Expand|Select|Wrap|Line Numbers
  1. <body bgcolor="#999999">
  2. <div id="content">
  3. <div id="content-top-bar"><p>This text appears a line down as to where you would expect it to be.<p/></div>
  4. </div>
  5. </body>
  6. body{
  7. background-color: #999999;
  8. margin: 0;
  9. padding: 0;
  10. }
  11.  
  12. #content{
  13. background-color: #ffffff;
  14. margin: 0 15% 0 15%;
  15. height: 600px;
  16. padding: 4px;
  17. }
  18.  
  19. #content-top-bar{
  20. background-color: #ffffff;
  21. height: 40px;
  22. border-width: 2px 2px 6px 2px;
  23. border-style: solid;
  24. border-color: #999999;
  25. }
  26.  
  27.  
Just spotted something- line 3 the closing paragraph tag is written as <p/>, this should be </p>.

Does that make any difference?

nathj
Jun 28 '07 #8
Markus
6,050 Recognized Expert Expert
Just spotted something- line 3 the closing paragraph tag is written as <p/>, this should be </p>.

Does that make any difference?

nathj

Nope. I really can't suss what the problem is. I've given up now but thanks anyway :)

xx
Jul 10 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3585
by: NotGiven | last post by:
I have a form that inserts records in a database. When I display records, the paragraphs don't show up. I am using dreamweaver MX, PHP, and MySQL.
16
3119
by: bluekite2000 | last post by:
I want Matrix A(B) to create shallow copy of B but A=B to create deep copy of B. Is that bad design? Why and why not?
6
6429
by: AFN | last post by:
I want to click a checkbox and have a 4 line (approx) paragraph appear beneath the checkbox, pushing the rest of the page down. And when unchecking the checkbox, the paragraph should disappear...
16
40608
by: lawrence | last post by:
I have a list of lists, and each lists has a heading. I want the heading to be grouped with its list. Can I do this: <p> <h5>My title</h5> <ul> <li>books</li> <li>dogs</li> </ul> </p>
1
1690
by: RJN | last post by:
Hi I have an onbeforeunload event where in I call a server side script to release some locks on the databse. function releaseLock() { __doPostBack('btnUnlock',''); } <body...
10
4868
by: Viken Karaguesian | last post by:
Hello everyone, Me again. Trying to learn some more :>) I hope I got the terminology right. How does a browser parse (correct term?) an HTML document. I'm sure that every browser does it a...
3
2300
by: gentsquash | last post by:
I'm trying to display a paragraph that has a centered phrase, such as this one, in the middle of the paragraph. An example is the section "End of semester project" on my course-page ...
3
1619
by: Cain | last post by:
A very simple regular expression test: var regx = /^\d+$/g; alert(regx.test("11") + ": " + regx.test("11")); And the output is "true: false". If I change to regx = new RegExp("^\\d+$",...
4
38368
by: rahullko05 | last post by:
i need to access the value of paragraph tag using dom in javascript. lets say there is <p id="test">this is test para </p> now how to access the value inside this para ie. "this is test para"? i...
0
7134
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
7012
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
7180
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
7392
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...
0
4605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.