{"id":36445,"date":"2018-02-26T03:01:12","date_gmt":"2018-02-25T17:01:12","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=36445"},"modified":"2018-02-26T08:46:08","modified_gmt":"2018-02-25T22:46:08","slug":"css-style-display-and-visibility-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/css-style-display-and-visibility-tutorial\/","title":{"rendered":"CSS Style Display and Visibility Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/styleequalsdisplay.htm\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"CSS Style Display and Visibility Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/styleequalsdisplay.gif\" title=\"CSS Style Display and Visibility Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">CSS Style Display and Visibility Tutorial<\/p><\/div>\n<p>In yesterday&#8217;s <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/ITblog\/emoji-name-search-geo-chart-worldbank-tutorial\/' title='Emoji Name Search Geo Chart WorldBank Tutorial '>Emoji Name Search Geo Chart WorldBank Tutorial <\/a> we mentioned the CSS topic of &#8220;invisibility&#8221; as a topic of interest in our <a target=_blank title='blank title='Reveal tutorials here' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/reveal'>&#8220;reveal&#8221;<\/a> thought patterns.<\/p>\n<p>Two of the best known ways in CSS to control invisibility (and, hence, visibility) are &#8230;<\/p>\n<table style='width:100%;'>\n<tr>\n<th>Invisible (style=)<\/th>\n<th>Visible (style=) Block Element<\/th>\n<th>Visible (style=) Inline Element (eg. span, a, img)<\/th>\n<\/tr>\n<tr>\n<td>display:none;<\/td>\n<td>display:block;<\/td>\n<td>display:inline;<\/td>\n<\/tr>\n<tr>\n<td>visibility:hidden;<\/td>\n<td>visibility:visible;<\/td>\n<td>visibility:visible;<\/td>\n<\/tr>\n<\/table>\n<p>The <a target=_blank title='CSS display and visibility property information from w3schools' href='https:\/\/www.w3schools.com\/css\/css_display_visibility.asp'>W3Schools display and visibility<\/a> CSS topic webpage is succinct in telling you the difference, as below &#8230;<\/p>\n<blockquote cite='https:\/\/www.w3schools.com\/css\/css_display_visibility.asp'><p>\nHiding an element can be done by setting the display property to none. The element will be hidden, and the page will be displayed as if the element is not there:<br \/>\n<br \/>\nExample<br \/>\nh1.hidden {<br \/>\n    display: none;<br \/>\n}<br \/>\n<br \/>\nvisibility:hidden; also hides an element.<br \/>\n<br \/>\nHowever, the element will still take up the same space as before. The element will be hidden, but still affect the layout\n<\/p><\/blockquote>\n<p>Which got us to go back to a previous tutorial called <a title='CSS Style Display Primer Tutorial' href='#csssdpt'>CSS Style Display Primer Tutorial<\/a> where we wrote some HTML and CSS and Javascript to show the <i>display<\/i> CSS property &#8220;in action&#8221;, that we &#8220;flesh out&#8221; today, adding in the layer of CSS property <i>visibility<\/i> into the mix as well.<\/p>\n<p>In terms of &#8220;reveal&#8221; thoughts though, it may be more the go for you (with a project you are working on) to just use one or the other CSS property depending on whether you want to &#8230;<\/p>\n<ul>\n<li>&#8220;reveal&#8221; a surprise &#8230; and have the HTML burst onto the scene via the <i>display<\/i> property &#8230; or &#8230;<\/li>\n<li>&#8220;reveal&#8221; by easing the user into thinking there may appear something &#8220;in a set aside slot&#8221; should I choose a certain course of actions, via the use of the <i>visibility<\/i> property<\/li>\n<\/ul>\n<p>Again, you can download source code and rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/styleequalsdisplay.html-GETME' title=\"styleequalsdisplay.html\">styleequalsdisplay.htm<\/a> and\/or try it out at this <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/styleequalsdisplay.htm\" title=\"Click picture\">live run<\/a> link and\/or <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/styleequalsdisplay.html-GETME' title=\"styleequalsdisplay.html\">see what changed<\/a> to involve the <i>visibility<\/i> property in this &#8220;reveal&#8221; topic tutorial.<\/p>\n<hr>\n<p id='csssdpt'>Previous relevant <a target=_blank title='CSS Style Display Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/css-style-display-primer-tutorial\/'>CSS Style Display Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/styleequalsdisplay.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"CSS Style Display Primer Tutorial\"\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/styleequalsdisplay.jpg\" title=\"CSS Style Display Primer Tutorial\"\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">CSS Style Display Primer Tutorial<\/p><\/div>\n<blockquote><p>Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation semantics (the look and formatting) of a document written in a markup language. Its most common application is to style web pages written in HTML and XHTML, but the language can also be applied to any kind of XML document, including plain XML, SVG and XUL.<\/p><\/blockquote>\n<p><a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/styleequalsdisplay.html'>Tutorial<\/a> &#8230;<\/p>\n<p>Cascading Style Sheet methodology is a good technique in order to separate document content from document presentation.  For the same content, two different CSS approaches can produce vastly different browser outputs.<\/p>\n<p>With today&#8217;s tutorial we concentrate on CSS within HTML and specifically the HTML object&#8217;s <a target=_blank title='style display property information from w3schools ... thanks' href='http:\/\/www.w3schools.com\/jsref\/prop_style_display.asp'>style.display property<\/a>, which has a huge number of choices, (and is heavily used by many web designers when building up web pages, I find, being a very close friend with Javascript and the DOM) and have a <a target=_blank title='Live Run' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/styleequalsdisplay.html'>live run<\/a> link for you to use with which to experiment.  The parent HTML element of our images of Nala the dog is a <i>div<\/i> element whose own style.display property is shown to you in the document window&#8217;s title.<\/p>\n<p>You can download source code and rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/styleequalsdisplay.html_GETME' title=\"styleequalsdisplay.html\">styleequalsdisplay.html<\/a><\/p>\n<p>Thanks to <a target=_blank title='CSS information from Wikipedia ... thanks' href='http:\/\/en.wikipedia.org\/wiki\/Cascading_Style_Sheets'>Wikipedia<\/a> for the quote above.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d10537' onclick='var dv=document.getElementById(\"d10537\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=CSS\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d10537' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d36445' onclick='var dv=document.getElementById(\"d36445\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/css\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d36445' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In yesterday&#8217;s Emoji Name Search Geo Chart WorldBank Tutorial we mentioned the CSS topic of &#8220;invisibility&#8221; as a topic of interest in our<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37],"tags":[2486,281,341,1549,576,590,2487,652,997,1063,1319,2485],"class_list":["post-36445","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-block","tag-css","tag-display","tag-element","tag-html","tag-image","tag-inline","tag-javascript","tag-programming","tag-reveal","tag-tutorial","tag-visibility"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/36445"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=36445"}],"version-history":[{"count":7,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/36445\/revisions"}],"predecessor-version":[{"id":36457,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/36445\/revisions\/36457"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=36445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=36445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=36445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}