HighDots Forums  

Help with <p> margins inside <div> please!

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Help with <p> margins inside <div> please! in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
slim
 
Posts: n/a

Default Help with <p> margins inside <div> please! - 05-16-2004 , 01:14 PM






hi again all,

i am still working on the website as mentioned in earlier threads and
have hit another snag...

http://awash.demon.co.uk/index.php

http://awash.demon.co.uk/vd.css

the php is pulling a name and placing it under the thumbnail (the text is
red) in a <p>. i have successfully set the colour to red through the
stylesheet, however, no notice is being taken of:

margin-top:0.2em;

or, indeed when i was playing about, this:

font-size:80%;

can anybody please let me know what i'm doing wrong? i'm guessing these
formatting instructions are being superceded by something else. if that
is the case, i have no idea what!

thanks in advance for any pointers. oh, and feel free to pull apart the
rest of the site for bad practice, i'm open to comments to improve the
code.

cheers
--
slim

Reply With Quote
  #2  
Old   
slim
 
Posts: n/a

Default Re: Help with <p> margins inside <div> please! - 05-16-2004 , 02:00 PM






|| name | slim <slim (AT) antiCorp (DOT) invalid> | message |
Quote:
| news:Xns94EBB9EE42392slimantiCorp (AT) 38 (DOT) 144.126.106: ||

hi again all,
<snip>

<snip>

Quote:
thanks in advance for any pointers. oh, and feel free to pull apart
the rest of the site for bad practice, i'm open to comments to improve
the code.

cheers
--
slim

not to worry - i fixed the <p> margin problem using a different
technique. the other comments would still be appreciated if you have 2
mins to spare
--
slim


Reply With Quote
  #3  
Old   
Spartanicus
 
Posts: n/a

Default Re: Help with <p> margins inside <div> please! - 05-16-2004 , 03:03 PM



slim <slim (AT) antiCorp (DOT) invalid> wrote:

Quote:
feel free to pull apart the
rest of the site for bad practice, i'm open to comments to improve the
code.

XHTML 1.0 Transitional
Using XHTML is silly, Transitional is for legacy documents, newly
authored documents should use Strict.

Quote:
div id="header"><h1
Why the div wrapper? H1 is a block level element, styles you have
attached to the wrapper div can be added to the H1.

Quote:
div id="navigation"
That's a list.

Quote:
p
span class="current">latest</span
That's not a paragraph.

Quote:
input type="text" name="criteria" style="width:6em;"
Move the inline css to the external stylesheet.

Quote:
&nbsp;
Margins should be specified via css.

Quote:
div id="contentwrap"
div id="rightcol"
h2>latest tees</h2

div class="teeblock_outercontainer"
Div/span soup.

Quote:
div class="spacer">&nbsp;</div
Again, margins should be specified with css.

Quote:
img src='./images/tees/thumbs/t_shitwizard.jpg' class='tee_thumbnail' alt='you are the shitwizard!'/
The images should not be resized by the browser, and definitely not by
specifying the desired dimensions in css.

--
Spartanicus


Reply With Quote
  #4  
Old   
John Moyer
 
Posts: n/a

Default Re: Help with <p> margins inside <div> please! - 05-16-2004 , 03:24 PM



Spartanicus wrote:
Quote:
slim <slim (AT) antiCorp (DOT) invalid> wrote:


feel free to pull apart the
rest of the site for bad practice, i'm open to comments to improve the
code.


XHTML 1.0 Transitional


Using XHTML is silly, Transitional is for legacy documents, newly
authored documents should use Strict.

It seems to me that transitional is useful so that one may apply a
background image and colors for browsers that cannot see the style
sheet. How is this incorrect for new documents?

John Moyer
http://www.rsok.com/~jrm/


Reply With Quote
  #5  
Old   
slim
 
Posts: n/a

Default Re: Help with <p> margins inside <div> please! - 05-16-2004 , 06:47 PM



|| name | Spartanicus <me (AT) privacy (DOT) net> | message |
Quote:
| news:nsdfa0dnm55j5fgskottsqbpnpcrn1b9c0 (AT) news (DOT) spartanicus.utvinternet.i
| e: ||

slim <slim (AT) antiCorp (DOT) invalid> wrote:

feel free to pull apart the
rest of the site for bad practice, i'm open to comments to improve the
code.

XHTML 1.0 Transitional

Using XHTML is silly, Transitional is for legacy documents, newly
authored documents should use Strict.

i tried to change this, checked it out in 3 browsers and found a total
mess in ie6 & opera7.1. although, i think that may have been me tinkering
before. i will leave this as is until i sort out my current problems and
then change it.

Quote:
div id="header"><h1

Why the div wrapper? H1 is a block level element, styles you have
attached to the wrapper div can be added to the H1.

when i take away the containing div, the header does not accept all the
style attributes i give it and does not display the same. for example, in
firefox, there is a gap between the bottom of header.jpg and the bottom
border. is there some part of <h> tags that overrules styles i apply?

Quote:
div id="navigation"

That's a list.

good point. that's kind of done, except i'm still using a div to frame
it, or <ul> won't take the style attributes i need to keep the design the
same.

Quote:
p
span class="current">latest</span

That's not a paragraph.

also fixed, thanks.

Quote:
input type="text" name="criteria" style="width:6em;"

Move the inline css to the external stylesheet.

have done, thank you.

Quote:
&nbsp;

Margins should be specified via css.

this was used as part of a fix i found whilst browsing: i want to display
the dotted boxes containing each t-shirt in a row until they need to
break for a new line, this trick was recommended to fix the fact that
they float:left and so occupy no space.

is there a better way to do this? i am currently using a slightly
different version of the same workaround, i'd like to be able to achieve
the boxes displaying as i describe legitimately if possible.

Quote:
div id="contentwrap"
div id="rightcol"
h2>latest tees</h2

div class="teeblock_outercontainer"

Div/span soup.

too many? the contentwrap div was used to fix a bug (which has now
reappeared) where the right column was appearing after the left column
vertically.

the rightcol div is then defined to house the various parts 10em across
so as to meet the leftcol - is this not necessary then?

and finally, the divs used to construct the t-shirt dotted boxes were the
only way i could see to achieve the look i wanted without using a table -
would you be able to suggest a better way of achieving that style with
cleaner code?

i'm new(ish) to this and willing to learn, but i'm kind of putting things
together as i pick it up, so it's not always the best approach.

Quote:
div class="spacer">&nbsp;</div

Again, margins should be specified with css.

see my response above. i'd love to know how to eliminate this if
possible.

Quote:
img src='./images/tees/thumbs/t_shitwizard.jpg' class='tee_thumbnail'
alt='you are the shitwizard!'/

The images should not be resized by the browser, and definitely not by
specifying the desired dimensions in css.

really? i thought i would be doing the user a favour by defining a fixed
aspect ratio in ems so the images would resize with the user's font.
could you explain why it is bad practice?

thanks very much for all the critique - it's been a help. now if only i
could fix that damned right column, i would move on to sorting out the
other bits!
--
slim


Reply With Quote
  #6  
Old   
Spartanicus
 
Posts: n/a

Default Re: Help with <p> margins inside <div> please! - 05-17-2004 , 03:16 AM



slim <slim (AT) antiCorp (DOT) invalid> wrote:

Quote:
Using XHTML is silly, Transitional is for legacy documents, newly
authored documents should use Strict.

i tried to change this, checked it out in 3 browsers and found a total
mess in ie6 & opera7.1.
Switching to Strict results in standard compliant rendering, it exposes
faults/omissions in your html/css that are masked by Quirk mode
rendering.

Quote:
Why the div wrapper? H1 is a block level element, styles you have
attached to the wrapper div can be added to the H1.

when i take away the containing div, the header does not accept all the
style attributes i give it and does not display the same. for example, in
firefox, there is a gap between the bottom of header.jpg and the bottom
border. is there some part of <h> tags that overrules styles i apply?
A browser applies default style values for any element, it's up to you
to change them if these result in undesired rendering.

Quote:
That's a list.

good point. that's kind of done, except i'm still using a div to frame
it, or <ul> won't take the style attributes i need to keep the design the
same.
Again there is no need, <ul> is also a block level element, styles
currently attached to the div can be added to the <ul>.

Quote:
&nbsp;

Margins should be specified via css.

this was used as part of a fix i found whilst browsing: i want to display
the dotted boxes containing each t-shirt in a row until they need to
break for a new line, this trick was recommended to fix the fact that
they float:left and so occupy no space.

is there a better way to do this? i am currently using a slightly
different version of the same workaround, i'd like to be able to achieve
the boxes displaying as i describe legitimately if possible.
Make a minimized test case and I'll have a look.

Quote:
Div/span soup.

too many? the contentwrap div was used to fix a bug (which has now
reappeared) where the right column was appearing after the left column
vertically.
Adding spurious markup is not the way to fix problems, tackle it at the
source by learning more about how css works. Ask here if you get stuck,
one problem per post and a minimized test case greatly increases your
chances of someone helping out.

Quote:
the rightcol div is then defined to house the various parts 10em across
so as to meet the leftcol - is this not necessary then?
At most you need 3 generic block level wrappers (<div>'s) for a site
like this, one for the header/navbar, one for the left col and one for
the content next to the left col. But you've got far more div/span
wrappers than that.

Quote:
and finally, the divs used to construct the t-shirt dotted boxes were the
only way i could see to achieve the look i wanted without using a table -
would you be able to suggest a better way of achieving that style with
cleaner code?

i'm new(ish) to this and willing to learn, but i'm kind of putting things
together as i pick it up, so it's not always the best approach.

div class="spacer">&nbsp;</div

Again, margins should be specified with css.

see my response above. i'd love to know how to eliminate this if
possible.
Redoing an entire page is a lot of work, break it down for us.

Quote:
The images should not be resized by the browser, and definitely not by
specifying the desired dimensions in css.

really? i thought i would be doing the user a favour by defining a fixed
aspect ratio in ems so the images would resize with the user's font.
could you explain why it is bad practice?
Browsers do a poor job at resizing images
Images don't need to resize with a user's font setting
Images larger than needed take longer to download
Images should remain the same size when a page is viewed sans css

--
Spartanicus


Reply With Quote
  #7  
Old   
slim
 
Posts: n/a

Default Re: Help with <p> margins inside <div> please! - 05-17-2004 , 08:00 AM



|| name | Spartanicus <me (AT) privacy (DOT) net> | message |
Quote:
| news:vunga0lvfnfh46oisb6hnfhbaoetmdm02o (AT) news (DOT) spartanicus.utvinternet.i
| e: ||

Switching to Strict results in standard compliant rendering, it
exposes faults/omissions in your html/css that are masked by Quirk
mode rendering.
i see, thanks. once these problems are fixed, i will switch over and then
fix any problems that entails.

Quote:
A browser applies default style values for any element, it's up to you
to change them if these result in undesired rendering.
again, i see. i have fixed this, thank you.

Quote:
Again there is no need, <ul> is also a block level element, styles
currently attached to the div can be added to the <ul>.
and this is fixed too - you're helping a great deal, thanks.

Quote:
this was used as part of a fix i found whilst browsing: i want to
display the dotted boxes containing each t-shirt in a row until they
need to break for a new line, this trick was recommended to fix the
fact that they float:left and so occupy no space.

is there a better way to do this? i am currently using a slightly
different version of the same workaround, i'd like to be able to
achieve the boxes displaying as i describe legitimately if possible.

Make a minimized test case and I'll have a look.

i have made a page here:

http://awash.demon.co.uk/vd_test.php
http://awash.demon.co.uk/vd_test.css

which contains just the elements needed to display the tee-shirts in the
way i would like them to look. this works the way it is outside of the
main page.

although, as you say, it's not good markup due to the number of block
elements. i suspect this may be the cause of other problems (see below).

Quote:
Adding spurious markup is not the way to fix problems, tackle it at
the source by learning more about how css works. Ask here if you get
stuck, one problem per post and a minimized test case greatly
increases your chances of someone helping out.
good point. i did ask here and someone suggested that fix as a workaround
for the leftcol div affecting the rightcol div when styles were applied
to it - a problem was arising where the rightcol was placed below the
leftcol. when i first applied that fix it worked.

i have stripped down the page and there are minimised test cases are at:

http://awash.demon.co.uk/vd_coltest_works.php
http://awash.demon.co.uk/vd_coltest_broken.php
http://awash.demon.co.uk/vd_coltest.css

i have highlighted with html comments the part that seems to break the
layout. i think the two main presentation issues i have are related.

it would appear that using the spacer div trick to display the tee-shirt
blocks on the page one after the other, wrapping when necessary, is
breaking the columns. this can be seen working fine without the columns
in the first test case earlier in this reply.

my guess is that a problem with using float:left on the div
"tee_container" and then compensating with the spacer is responsible.

Quote:
At most you need 3 generic block level wrappers (<div>'s) for a site
like this, one for the header/navbar, one for the left col and one for
the content next to the left col. But you've got far more div/span
wrappers than that.

i have reduced the number of divs in the main page at:

http://awash.demon.co.uk/index.php

to just the left col, the content wrapper and the right col.

unfortunately, more divs are added by containers to house the tee shirt
blocks. perhaps this will be remedied by your reply to the question of
altering that layout - i'm keen to display the t-shirt blocks another way
if it can be done whilst maintaining presentation.

Quote:
Browsers do a poor job at resizing images
i see, that doesn't surprise me

Quote:
Images don't need to resize with a user's font setting
won't my page be less accessible if someone with bad sight resizes the
font larger and they are still presented with thumbs smaller in size
above it?

Quote:
Images larger than needed take longer to download
but surely the client would still download the same .jpg from my server
and then resize dynamically?

Quote:
Images should remain the same size when a page is viewed sans css
ahhhh, the penny snaps is there a better way to tackle the problem of
the thumbs remaining the same dimensions when font size is altered?

thanks again for all your help, the time you've spent and the pointers
you've given me. in future i will endeavour to ask questions here in the
format you have suggested.

cheers
--
slim


Reply With Quote
  #8  
Old   
Spartanicus
 
Posts: n/a

Default Re: Help with <p> margins inside <div> please! - 05-18-2004 , 05:11 AM



slim <slim (AT) antiCorp (DOT) invalid> wrote:

Quote:
Make a minimized test case and I'll have a look.

i have made a page here:

http://awash.demon.co.uk/vd_test.php
That's simply a section of your page, a minimizes test case has been
stripped down to the bare minimum needed to illustrate a single issue.
The point is to make it easier for others to help you, it's a chore
having to work your way through someone else's code to get to the real
problem. You are very familiar with your code, others aren't.

Posting a link to a site's linked stylesheet is helpful when asking for
a site review, for a minimized test case it's a bother. To get to the
issue I now have to juggle a news reader window to read what the problem
is, a window with your css, a window with your markup and a browser
window.

A minimized test case should look like this:
http://www.spartanicus.utvinternet.i...loat_issue.htm

All you have to do to is to open a single browser window, no source view
is needed, the problem is described on the page itself, both the css and
html code is displayed. The html/css code has been stripped of anything
that isn't directly related to the issue.

Indenting your code also helps others to make sense of your code,
especially nested div's are a pain to decipher without indented code.

--
Spartanicus


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.