/    Sign up×
Community /Pin to ProfileBookmark

Hiding text in a <div>

I need to place some text in a <div></div> area of a document, but I need the text to be invisible (because a script on the page needs to read it at some time). How do I do that? I am using IE. I can make no assumptions about background colors and such (so making it the same color as the background won’t work).

Thanks.

Deltareum

to post a comment
HTML

6 Comments(s)

Copy linkTweet thisAlerts:
@DaveSWJun 05.2003 — how about:

<span style="display:none;">all hidden content</span>

or put it in the div tag to hide the whole div

dave
Copy linkTweet thisAlerts:
@brendandonhueJun 05.2003 — <div id="mydiv" style="visibility:hidden">
Copy linkTweet thisAlerts:
@DaveSWJun 05.2003 — deltareum: the difference between these is that display:none will not display the text, so it won't affect the layout. visibility:hidden hides it, so it will alter your layout.

(I couldn't remember the value for visibility offhand which was why i didn't post it)

dave
Copy linkTweet thisAlerts:
@deltareumauthorJun 05.2003 — Thanks! You people are the greatest!

I am using <div style="display:none;"> now and it works like a champ.

What versions of IE and Netscape will this work with?

Deltareum
Copy linkTweet thisAlerts:
@nkaisareJun 05.2003 — What versions of IE and Netscape will this work with?[/quote]
IE4+, NS4+

However, both insert a blank line.

IE5+ and NS6+ do not insert a blank line (which is appropriate behavior)
Copy linkTweet thisAlerts:
@Robert_WellockJun 06.2003 — M$ IE 6.0 fails and inserts a blank line under some circumstances, when it [i]shouldn't[/i] the same went for Opera 6.0 but in Opera 7.xx the problem was resolved.

So M$ has buggy support for display:none;.
×

Success!

Help @deltareum spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...