{"id":342681,"date":"2021-06-21T12:36:30","date_gmt":"2021-06-21T19:36:30","guid":{"rendered":"https:\/\/css-tricks.com\/?page_id=342681"},"modified":"2021-07-01T08:36:40","modified_gmt":"2021-07-01T15:36:40","slug":"content-visibility","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/c\/content-visibility\/","title":{"rendered":"content-visibility"},"content":{"rendered":"\n

The content-visibility<\/code> property in CSS indicates to the browser whether or not an element\u2019s contents should be rendered at initial load time. So, as the browser starts loading content and is playing it on the screen, this property allows us to step in and tell the browser not<\/em> to load the contents of an element until it\u2019s needed. Think of it sort of<\/em> like lazy loading in the sense that an off-screen element\u2019s children are not rendered until they enter the viewport.<\/p>\n\n\n\n

.element {\n  content-visibility: hidden;\n}<\/code><\/pre>\n\n\n\n

The main point of using content-visibility<\/code> is performance. It can help to speed up page load because the browser is able to defer rendering elements that are not in the user\u2019s viewport until the user scrolls to them. The results can be dramatic. Here are the results of a performance test<\/a> that Una Kravets and Vladimir Levin put together showing the difference that content-visibility<\/code> can make on a typical webpage.<\/p>\n\n\n\n

\"\"
Source: web.dev<\/a><\/figcaption><\/figure>\n\n\n

Syntax<\/h3>\n\n\n
content-visibility: [visible | auto | hidden];<\/code><\/pre>\n\n\n\n