How to hide something using css??

  • Thread starter =?iso-8859-2?Q?Pawe=B3?=
  • Start date
?

=?iso-8859-2?Q?Pawe=B3?=

I have a following piece of code:
<html>
<head>
</head>
<body>
<p>123</p>
<p style="display:none" >456</p>
<p>789</p>
</body>
</html>

What I get in browser is:
123
<blank space>
789
What I would like to obtain is:
123
789

I simply don't want the browser to render anything.
Any ideas??
 
B

brucie

in post: <
<p>123</p>
<p style="display:none" >456</p>
<p>789</p>

What I get in browser is:
123
<blank space>
789
What I would like to obtain is:
123
789

p{margin:0;}
 
S

Steve Pugh

Pawe³ said:
I have a following piece of code:

<p>123</p>
<p style="display:none" >456</p>
<p>789</p>

What I get in browser is:
123
<blank space>
789
What I would like to obtain is:
123
789

Caused by the default margins on the <p> elements.

If you had
<p>123</p>
<p>789</p>
it would render exactly the same.

p {margin: 0;}

Steve
 
S

Spartanicus

Pawe³ said:
I have a following piece of code:
<html>
<head>
</head>
<body>
<p>123</p>
<p style="display:none" >456</p>
<p>789</p>
</body>
</html>

What I get in browser is:
123
<blank space>
789
What I would like to obtain is:
123
789

<body>
<div>123</div>
<div>789</div>
</body>
 
R

Richard

Pawe³ said:
I have a following piece of code:
<html>
<head>
</head>
<body>
<p>123</p>
<p style="display:none" >456</p>
<p>789</p>
</body>
</html>

What I get in browser is:
123
<blank space>
789
What I would like to obtain is:
123
789

I simply don't want the browser to render anything.
Any ideas??


The <p> inherently inserts a blank line. It is equivelant to <br><br>.
Why do you have display:none then insert text?
If you want no blank lines between use:
123
<br>
789
 
K

kchayka

Richard said:
The <p> inherently inserts a blank line. It is equivelant to <br><br>.

No, it is not. <p> is paragraph markup, which has semantic meaning.
<URL:http://dictionary.reference.com/search?q=paragraph>
The blank line is the default margin all browsers put around paragraph
markup.

<br> has no semantic meaning, it is just a line break. UA's may also
strip out extra white space, so only one of those breaks may actually
render. This can create a serious readability problem.

<br><br> != <p>
 
K

KirstyH

Richard said:
Why do you have display:none then insert text?

I use
<SPAN style="display:none"> | </SPAN>
between links in my navigation list[1,2]. Thus when the page is viewed
without CSS I get

Link1 | Link2 | ... | LinkN

[1] Actually I use a class identifier and an external stylesheet
[2] Perhaps a <UL> would be more appropiate but then I need to go
through contortions to stop it appearing as a list when CSS _is_ enabled.

Kirsty
 
R

Ramen Junkie

kchayka said:
No, it is not. <p> is paragraph markup, which has semantic meaning.
<URL:http://dictionary.reference.com/search?q=paragraph>
The blank line is the default margin all browsers put around paragraph
markup.

<br> has no semantic meaning, it is just a line break. UA's may also
strip out extra white space, so only one of those breaks may actually
render. This can create a serious readability problem.

<br><br> != <p>


I avoid having the browser strip out my consecutive <br>s with &nbsp.

For example.

123<br>
&nbsp <br>
567<br>
 
K

KirstyH

Toby said:
KirstyH wrote:

[2] Perhaps a <UL> would be more appropiate but then I need to go
through contortions to stop it appearing as a list when CSS _is_ enabled.


Not difficult.

ul#nav { margin:0; padding:0; list-style:none }
ul#nav li { margin:0; padding:0 1em; display:inline }

I could have sworn I'd tried that and it didn't work! Thank-you. But
now of course I need display: none; for the "skip the links" ;-)

Kirsty
 
K

Karl Groves

KirstyH said:
Toby said:
KirstyH wrote:

[2] Perhaps a <UL> would be more appropiate but then I need to go
through contortions to stop it appearing as a list when CSS _is_
enabled.


Not difficult.

ul#nav { margin:0; padding:0; list-style:none }
ul#nav li { margin:0; padding:0 1em; display:inline }

I could have sworn I'd tried that and it didn't work! Thank-you. But
now of course I need display: none; for the "skip the links" ;-)

No, do not use display:none for a skip link
http://simon.incutio.com/archive/2003/09/13/screenReaders

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top