{Hide_text} CSS text hiding Summary Report

Source: Internet
Author: User

A recently prepared copyCSSHidden textDemoI have summarized several methods and hope to come up with the most perfect solution and put it into my own code snippets. However, at the end, I am stuck in a situation where I repeatedly overturn the conclusion. Because there are too many application scenarios and elements to consider, you can leave your browser blank. Different application terminals and tag structures have different optimal solutions. Therefore, rather than "stealing some laziness" at work, it is better to consolidate and accumulate basic knowledge and be more comfortable when balancing the need.

Because of your relatively low experience, the demo will inevitably have errors and omissions. If you find any problems, I hope you can point them out.

Method list demo

 1. unretained: display: none

Code snippet:
(X) HTML
<P class = "hide_display"> I am a text for Soy Sauce </p> CSS
/* Brute force hiding */
. Hide_display {display: none ;}

Compatibility:

Advantages:

  • Convenient and fast
  • Good compatibility

Disadvantages:

  • Screen reader cannot read
  • Hyperlink not applicable
  • The image replaces the background of text that requires other labels
  • Affected search ranking
  • A large amount of use is easy to think of as SEO cheating

2. compromise options: overflow: hidden/position: absolute/visibility: hidden

Code snippet:

(X) HTML
<Span class = "hide_overflow"> I am the text of No. 1 soy sauce. </span>
<P class = "hide_position"> I am the text of soy sauce 2. </p>
<P class = "hide_visibility"> I am the text of No. 3 soy sauce. </p>CSS
/* Hide the element from the text stream so that the element does not affect other elements */
. Hide_overflow {
Height: 0px;
Overflow: hidden;
Display: block;/* In-Row Element needs */
Float: left;/* exit the Document Stream or position: absolute ;*/
}
/* Locates outside the visible range and leaves the text stream so that the element does not affect other elements */
. Hide_position {
Position: absolute;
Left:-32767px;
}
/* Same principle as. hide_position */
. Hide_visibility {
Visibility: hidden;
Position: absolute;/* disconnects from the document stream */
Margin-left:-32767px;
}

  • Three pages in total:
  • Previous Page
  • 1
  • 2
  • 3
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.