Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > add line breaks through css?

Reply
Thread Tools

add line breaks through css?

 
 
Greg N.
Guest
Posts: n/a
 
      08-11-2005
I have a some text that is include (through PHP) in different pages:

<div class=mystuff>item 1</div>
<div class=mystuff>item 2</div>
<div class=mystuff>item 3</div>

On one type of page, these items should appear on separate lines, as if
they were sparated by <br>.

On another type of page, the items should appear side by side, separated
by spaces.

The difference between the two cases should be coded in CSS only. Can
anybody give me a hint on how to do this, if it is possible?

--
Gregor's Motorradreisen:
http://hothaus.de/greg-tour/
 
Reply With Quote
 
 
 
 
dingbat@codesmiths.com
Guest
Posts: n/a
 
      08-11-2005

Greg N. wrote:

> On one type of page, these items should appear on separate lines, as if
> they were sparated by <br>.
>
> On another type of page, the items should appear side by side, separated
> by spaces.


Investigate display:block; and display:inline;

 
Reply With Quote
 
 
 
 
Spartanicus
Guest
Posts: n/a
 
      08-11-2005
"Greg N." <(E-Mail Removed)> wrote:

>I have a some text that is include (through PHP) in different pages:
>
><div class=mystuff>item 1</div>
><div class=mystuff>item 2</div>
><div class=mystuff>item 3</div>


Div soup, use the appropriate structural and semantic markup instead.

>On one type of page, these items should appear on separate lines, as if
>they were sparated by <br>.
>
>On another type of page, the items should appear side by side, separated
>by spaces.
>
>The difference between the two cases should be coded in CSS only. Can
>anybody give me a hint on how to do this, if it is possible?


Depends on the markup, for a list:

ul li{display:inline} to switch it to inline ("list-item" is the
default).

--
Spartanicus
 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      08-11-2005
"Greg N." <(E-Mail Removed)> wrote:

> I have a some text that is include (through PHP) in different pages:
>
> <div class=mystuff>item 1</div>
> <div class=mystuff>item 2</div>
> <div class=mystuff>item 3</div>


Is it really something that has no logical structure that is describable in
HTML? Not a list, for example? Not paragraphs?

> On one type of page, these items should appear on separate lines, as if
> they were sparated by <br>.


That's what you are saying by using <div>.

> On another type of page, the items should appear side by side, separated
> by spaces.


Well, then change <div> to <span> on that page. Though there is probably
something odd going on here, and you are solving the wrong problem, and we
cannot solve your real problem because you gave no URL.

> The difference between the two cases should be coded in CSS only.


No, it shouldn't. See http://css.nu/pointers/CSS-caveats.html

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


 
Reply With Quote
 
Greg N.
Guest
Posts: n/a
 
      08-11-2005
Jukka K. Korpela wrote:

> Though there is probably something odd going on here,
> and you are solving the wrong problem, and we
> cannot solve your real problem because you gave no URL.


What I was talking about are the navigation segments in

http://hothaus.de/greg-tour-2003/fyrom.htm
and
http://coolhaus.de/iv/03/iv.php?widt...g/xl-x2_32.jpg

The problem is solved. I got the answers that I was looking for in the
first two responses to my question.

--
Gregor's Motorradreisen:
http://hothaus.de/greg-tour/

 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      08-12-2005
"Greg N." <(E-Mail Removed)> wrote:

> What I was talking about are the navigation segments in

- -
> The problem is solved.


Really? So why did you tell _now_ what the real problem was? Especially
when you say:

> I got the answers that I was looking for in the
> first two responses to my question.


I'm pretty sure you have implemented some wrong answers to wrong problems.
You should have started from using simple and logical HTML markup, instead
of div soup, but you decided to dig yourself deeper.

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


 
Reply With Quote
 
Safalra
Guest
Posts: n/a
 
      08-13-2005
Jukka K. Korpela wrote:
> "Greg N." <(E-Mail Removed)> wrote:
> > I got the answers that I was looking for in the
> > first two responses to my question.

>
> I'm pretty sure you have implemented some wrong answers to wrong problems.
> You should have started from using simple and logical HTML markup, instead
> of div soup, but you decided to dig yourself deeper.


Surely "Spartanicus"'s suggestion to use list mark-up is The Right
Thing, given that the navigation is logically a list of links?

--
Safalra (Stephen Morley)
http://www.safalra.com/hypertext/

 
Reply With Quote
 
Greg N.
Guest
Posts: n/a
 
      08-14-2005
Jukka K. Korpela wrote:


> I'm pretty sure you have implemented some wrong answers to wrong problems.
> You should have started from using simple and logical HTML markup, instead
> of div soup, but you decided to dig yourself deeper.


The solution is not on the web site yet, but I now know what to do about
the problem.

I consider my problem solved.

Except that I'm not always sure what you're talking about ) Do you
disagree with what the first two respondents in this thread suggested? Why?

--
Gregor's Motorradreisen:
http://hothaus.de/greg-tour/
 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      08-14-2005
"Greg N." <(E-Mail Removed)> wrote:

> The solution is not on the web site yet, but I now know what to do
> about the problem.


That would be fine, but why are you telling us that without telling what
your solution is and what do you know about handling the problem? You
responded to my message without addressing anything I had written, and you
presented some URLs - with the first one containing a wrong approach in
markup (the way I predicted), so what should we think about this?

> I consider my problem solved.


I don't know whether you are referring to the problem in the Subject line
or the problem you described in the body of your first message, but I know
that the CSS code suggested does not solve either of them. But if you
consider your problem solved, maybe it was not either of them.

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


 
Reply With Quote
 
Greg N.
Guest
Posts: n/a
 
      08-14-2005
Jukka K. Korpela wrote:

>>The solution is not on the web site yet, but I now know what to do
>>about the problem.

>
> That would be fine, but why are you telling us that without telling what
> your solution is and what do you know about handling the problem?


I am going to mark up my navigation section as list items. I am going to
style the individual list items as "list-style-type:none" in the first
case, and "display:inline" in the second case.

This does what I asked for in my original post, and what I picked up
from the first two replies. I have tested it, and it works under IE and
FF:

<ul>
<li style="list-style-type: none">blabla
<li style="list-style-type: none">blubb blubb
<li style="list-style-type: none">tatata
</ul>

<ul>
<li style="display:inline">blabla
<li style="display:inline">blubb blubb
<li style="display:inline">tatata
</ul>

> You responded to my message without addressing anything I had written,


Well, I gave you the URLs you asked for.

Then, there was my requirement: The difference between the two cases
should be coded in CSS only.

I did not address your suggestion "Well, then change <div> to <span>"
because that does not meet my requirement.

You also said, "No, it shouldn't. See
http://css.nu/pointers/CSS-caveats.html" I did not address this comment
of yours because it was not a response to my question. We can elaborate
on that if you want.

> you presented some URLs - with the first one containing
> a wrong approach in markup


care to tell me what's wrong with it?

(the way I predicted), so what should we think about this?

What is it you're actually telling me? I'm puzzled. Honestly.

>>I consider my problem solved.

>
> I don't know whether you are referring to the problem in the Subject line
> or the problem you described in the body of your first message, but I know
> that the CSS code suggested does not solve either of them.


It does. See above.

--
Gregor's Motorradreisen:
http://hothaus.de/greg-tour/
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginner: read $array with line breaks line by line Marek Stepanek Perl Misc 12 09-02-2006 10:27 AM
Add paragraph breaks in textarea ThunStorm Javascript 2 03-09-2006 08:58 PM
Force multi line field value to output with line breaks? bernadou ASP .Net Web Controls 2 01-23-2006 01:23 PM
Re: javascript causing line breaks PJ ASP .Net 1 08-04-2003 12:56 AM
Parse an xml file with line breaks in the beginning Raj Mudaliar Perl 0 07-14-2003 06:00 PM



Advertisments