473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

css - cleanest way to make spacer

Hi,
i am going to make my pages more css and xhtml compatible.
Before i got athe following code:
---------------------
<p>first text</p>
<p><img src="spacer.gif" width="1" height="80" /></p>
<p>second text</p>
---------------------

By changing the value of the transparent spacer.gif i can arange the
second text on the page where i want it to.

Is there a good way to do this with css?
Jul 23 '05 #1
11 32697
Els
Wilhelm Kutting wrote:
Hi,
i am going to make my pages more css and xhtml compatible.
Before i got athe following code:
---------------------
<p>first text</p>
<p><img src="spacer.gif" width="1" height="80" /></p>
<p>second text</p>
---------------------

By changing the value of the transparent spacer.gif i can
arange the second text on the page where i want it to.

Is there a good way to do this with css?


Yes,
<p>first text</p>
<p class="second">second text</p>

And in your styles (so it'll work for all pages with a 'second-
class paragraph'):
p.second{margin-top:80px;}

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jul 23 '05 #2
Els wrote:
Wilhelm Kutting wrote:

Hi,
i am going to make my pages more css and xhtml compatible.
Before i got athe following code:
---------------------
<p>first text</p>
<p><img src="spacer.gif" width="1" height="80" /></p>
<p>second text</p>
---------------------

By changing the value of the transparent spacer.gif i can
arange the second text on the page where i want it to.

Is there a good way to do this with css?

Yes,
<p>first text</p>
<p class="second">second text</p>

And in your styles (so it'll work for all pages with a 'second-
class paragraph'):
p.second{margin-top:80px;}

This is margin 80px from the last paragraph
Can i use absolute margin from top of page, too?
Jul 23 '05 #3
Els
Wilhelm Kutting wrote:
<p>first text</p>
<p class="second">second text</p>

And in your styles (so it'll work for all pages with a
'second- class paragraph'):
p.second{margin-top:80px;}

This is margin 80px from the last paragraph
Can i use absolute margin from top of page, too?


Yes, but it's not called margin then.
p.second{position:absolute;top:80px}
will set the second paragraph exactly 80 pixels from the top of
the closest positioned parent.
Meaning: if the paragraphs are inside another div which also has
position:absolute, or position:relative, the 80 pixels are
calculated from the top of that div.

WARNING!!: don't even think about using the position property
until you really understand CSS.
Just one small little tiny disadvantage of setting the second
paragraph to 80px from the top of the page: What happens if the
first paragraph is higher because someone adjusted the font-
size?

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jul 23 '05 #4
Els wrote:
Wilhelm Kutting wrote:

<p>first text</p>
<p class="second">second text</p>

And in your styles (so it'll work for all pages with a
'second- class paragraph'):
p.second{margin-top:80px;}


This is margin 80px from the last paragraph
Can i use absolute margin from top of page, too?

Yes, but it's not called margin then.
p.second{position:absolute;top:80px}
will set the second paragraph exactly 80 pixels from the top of
the closest positioned parent.
Meaning: if the paragraphs are inside another div which also has
position:absolute, or position:relative, the 80 pixels are
calculated from the top of that div.

WARNING!!: don't even think about using the position property
until you really understandto CSS.
Just one small little tiny disadvantage of setting the second
paragraph to 80px from the top of the page: What happens if the
first paragraph is higher because someone adjusted the font-
size?

Tahnx, that is a really good point!
My objective is get the site working for blind people with css so i do
not use the absolute thing.
Jul 23 '05 #5
Els
Wilhelm Kutting wrote:
Els wrote:
WARNING!!: don't even think about using the position
property until you really understandto CSS.
Just one small little tiny disadvantage of setting the
second paragraph to 80px from the top of the page: What
happens if the first paragraph is higher because someone
adjusted the font- size?

Tahnx, that is a really good point!
My objective is get the site working for blind people with
css so i do not use the absolute thing.


Eh... to get the site working for blind people, the CSS won't
do anything...

Mark up your page with pure html first, but very simple, like:
<h1>Title</h1>
<p>
introduction
</p>
<h2>secondary title</h2>
<p>
information
</p>

etc.

Then, after you're sure it's all readable and accessible,
*then* you start to add CSS, so it will be visually nice
looking for non-blind people.

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jul 23 '05 #6
Wilhelm Kutting <wk******@arcor.de> wrote:
i am going to make my pages more css and xhtml compatible.
Only your intention to move to xhtml is on topic here, and the answer
is: don't. Xhtml currently serves no useful purpose, use html 4.01
Strict.
Is there a good way to do this with css?


comp.infosystems.www.authoring.stylesheets is the correct place for
questions regarding css, but instead of moving your questions there you
should at least make a minimum effort to learn the basics yourself.

I'm assuming that you can access the web, there's a plethora of
information on css there, use it.

--
Spartanicus
Jul 23 '05 #7
Els <el*********@tiscali.nl> wrote:
Yes,
<p>first text</p>
<p class="second">second text</p>

And in your styles (so it'll work for all pages with a 'second-
class paragraph'):
p.second{margin-top:80px;}


This is mostly off-topic for this group (and better suited for
c.i.w.a.stylesheets), but there are HTML issues involved in the sense
that HTML elements have some _default_ rendering in browsers. Partly this
behavior is (obscurely) described in the sample style sheets for HTML in
CSS specifications.

It is important to note in cases like this that paragraphs (p elements)
generally have a default top margin and a default bottom margin.
Moreover, by CSS rules the actual spacing between two consecutive p
elements is the larger of the first element's bottom margin and the
second element's top margin.

Thus, p.second{margin-top:80px;}, if applied by a browser, will set a
_minimum_ vertical spacing between the paragraphs. It is quire probable
that it will also set the actual spacing, but there is really no law
against using a browser with, say, a font size of 100 pixels, in which
case the first paragraph's bottom margin is probably larger than 80
pixels.

The morale is that you should normally not use the px unit but set e.g. a
top margin using the em unit, which equals the size (height) of the font
in use.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 23 '05 #8
Els wrote:
Eh... to get the site working for blind people, the CSS won't do
anything...


Not yet. But in principle, there is room for an aural stylesheet.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 23 '05 #9
Els
Brian wrote:
Els wrote:
Eh... to get the site working for blind people, the CSS
won't do anything...


Not yet. But in principle, there is room for an aural
stylesheet.


True, and of course "display:none" does actually interfere, as
speech browsers seem to honour that value, but as the OP is only
starting out using CSS (or so it seems) I thought I'd generalize
just a little bit :-)

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jul 23 '05 #10
Els wrote:
"display:none" does actually interfere, as speech browsers seem to
honour that value,
You mean screen readers? I suppose there's not much they can do, since
they only read what a screen displays, or would display. Is there a true
aural browser? I don't know of one.
but as the OP is only starting out using CSS (or so it seems) I
thought I'd generalize just a little bit :-)


The right choice, I imagine.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 23 '05 #11
Els
Brian wrote:
Els wrote:
"display:none" does actually interfere, as speech browsers
seem to honour that value,


You mean screen readers? I suppose there's not much they
can do, since they only read what a screen displays, or
would display. Is there a true aural browser? I don't know
of one.


For the difference between screen readers and speech browsers I
would like to refer you to Jake, he's the expert (or so I think)
:-)
I have no clue about these type of eh.. "surf progams"
whatsoever.

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jul 23 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Richard Barnet | last post by:
I'm trying to style a line break, something like this: <br class="spacer" /> via CSS, but none of the following seems to have any effect. Any ideas? br.spacer { clear: both; height: 50px;...
2
by: Daniel Lidström | last post by:
Hi, I would like to know the cleanest way to change the serialization of my Line class from: <Line staStart="2327.02" length="10.00000003390744"> <End>549016.570965 57945.741122</End>...
0
by: moondaddy | last post by:
using vb.net I have a datalist where the Repeat layout has: Columns 2 Direction Horizontal Layout Table I want to put a spacer column inbetween the 2 columns for better control of...
0
by: | last post by:
ASP.NET 2.0 simplifies binding datasources to controls like the repeater. These new methods allow nearly code-less mechanisms to dump data to a page. I like this new feature a whole lot. HTML...
4
by: | last post by:
I'm finishing an .ascx control that takes custom properties. I've made a generalized administrative form that can be made specific by calling the user control with a bunch of parameters (e.g. ...
1
by: shapper | last post by:
Hello, I am working on an Asp.Net 2.0 web site and I need to set the height of a panel to 200px. Should I use the Asp.Net 2.0 panel height property or should I try to use a spacer.gif image?...
2
by: neuneudr | last post by:
Hi everybody, I'm scratching my head with a CSS problem. I want to have the following (the two pics have these size for a good reason, the whole point of the page is basically to show these...
3
by: eye ohh ewe | last post by:
Im a bit of a novice to web design and have constructed this site: www.uniguild.co.uk It displays well in IE and Safari but when in firefox the spacer gif's I used to pad it out show with a...
0
by: nataraj jaideep | last post by:
Hi, I created a spacer in CSS and called in HTML inside a div tag, so that space will occur between one div to another in webpage. But the .whitespacer is working fine with IE8 and in IE6 the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.