473,564 Members | 2,768 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 5126
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
3591
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
3123
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
6433
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 and the part below should push back up again. How?
16
40625
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
1695
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 onbeforeunload="releaseLock();>
10
4882
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 little differently. Do they simply just read a document top-to-bottom and left-to-right and just display elements in the order in which they encounter...
3
2308
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 http://www.math.ufl.edu/~squash/course.calc3.html
3
1621
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+$", "g"); Then the output is the same.
4
38375
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 have tried: var text = document.getElementById("test").value, also tried document.getElementById("test").firstChild but none of them return...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
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 we have to send another system
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.