{"id":360,"date":"2014-05-21T15:57:21","date_gmt":"2014-05-21T14:57:21","guid":{"rendered":"https:\/\/blogs.ncl.ac.uk\/t4\/?p=360"},"modified":"2014-05-21T15:57:21","modified_gmt":"2014-05-21T14:57:21","slug":"styling-content-using-html-and-css","status":"publish","type":"post","link":"https:\/\/blogs.ncl.ac.uk\/t4\/2014\/05\/21\/styling-content-using-html-and-css\/","title":{"rendered":"Styling Content using HTML and CSS"},"content":{"rendered":"<p>Content on webpages is described using HTML and the layout and look of it can be styled using a language called <strong>CSS: Cascading Style Sheets<\/strong>.<\/p>\n<p>HTML and CSS is largely out of scope for this blog, as it&#8217;s well described on a number of other excellent sites (I recommend <a href=\"http:\/\/www.w3schools.com\/css\/default.asp\">w3schools<\/a>) and we largely aim our T4 provision at content providers not designers or developers &#8211; if you wish to work with a custom template and designer, please contact us using <a href=\"mailto:\/\/it.servicedesk@ncl.ac.uk\">it.servicedesk@ncl.ac.uk<\/a>, and we&#8217;ll discuss your requirements.<\/p>\n<p>Please note that CSS and HTML coding is <em>not<\/em> supported by ISS beyond providing this documentation and links &#8211; site owners are expected to develop their own knowledge of HTML\/CSS or have an appropriate budget to work with a designer\/developer.<\/p>\n<h2>CSS by Example<\/h2>\n<p>The site below (Years Ahead) has three requirements:<\/p>\n<ol>\n<li>Remove the Header from the page as it duplicates the Banner (highlighted in red)<\/li>\n<li>Change the links under the pictures so that they&#8217;re in coloured blocks joined to the images (highlighted in yellow). The grid has been created using the <a title=\"Three or four column grid layouts\" href=\"https:\/\/blogs.ncl.ac.uk\/t4\/2014\/02\/26\/three-or-four-column-grid-layouts\/\">threecol class<\/a>.<\/li>\n<li>Amend the style of the navigation buttons as the dark blue template makes them difficult to read (highlighted in blue)<\/li>\n<\/ol>\n<p><a href=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-361\" alt=\"Years Ahead\" src=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-300x161.jpg\" width=\"300\" height=\"161\" srcset=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-300x161.jpg 300w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-1024x550.jpg 1024w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-500x268.jpg 500w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead.jpg 1600w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h2>1: Hiding the Header on the Homepage<\/h2>\n<p>Go to the homepage section, and add a piece of content of the type\u00a0Raw HTML\/Javascript. Give it a name &#8211; &#8220;Styles for Homepage&#8221; is a good name. Note that these styles will only effect the section in which they&#8217;re added.<\/p>\n<p><a href=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/rawhtml.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-362\" alt=\"rawhtml\" src=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/rawhtml-300x90.jpg\" width=\"300\" height=\"90\" srcset=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/rawhtml-300x90.jpg 300w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/rawhtml-1024x308.jpg 1024w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/rawhtml-500x150.jpg 500w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/rawhtml.jpg 1144w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Paste the following into the content area:<\/p>\n<p>&lt;style&gt;<br \/>\nh3<br \/>\n{<br \/>\ndisplay:none;<br \/>\n}<br \/>\n&lt;\/style&gt;<\/p>\n<p><a href=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/CSS-Remove-Header.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-363\" alt=\"CSS-Remove-Header\" src=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/CSS-Remove-Header-300x90.jpg\" width=\"300\" height=\"90\" srcset=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/CSS-Remove-Header-300x90.jpg 300w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/CSS-Remove-Header-1024x308.jpg 1024w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/CSS-Remove-Header-500x150.jpg 500w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/CSS-Remove-Header.jpg 1144w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h2>What does this mean?<\/h2>\n<ul>\n<li>&lt;style&gt; is a html tag that says we&#8217;re editing the stylesheet.<\/li>\n<li>h3 is a css selector that represents header level 3 &#8211; which is what the page content titles usually are in our template.<\/li>\n<li>The curly brackets contain the rules, and display:none; is the rule we&#8217;re applying.<\/li>\n<li>&lt;\/style&gt; closes the html tag.<\/li>\n<\/ul>\n<p>Publish and approve &#8211; you&#8217;re done, the header is removed.<\/p>\n<p><a href=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-Years-Ahead-Newcastle-University.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-364\" alt=\"Years Ahead  Years Ahead  Newcastle University\" src=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-Years-Ahead-Newcastle-University-300x243.png\" width=\"300\" height=\"243\" srcset=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-Years-Ahead-Newcastle-University-300x243.png 300w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-Years-Ahead-Newcastle-University-1024x830.png 1024w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-Years-Ahead-Newcastle-University-370x300.png 370w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-Years-Ahead-Newcastle-University.png 1041w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>2: Changing the boxes so that they contain a colour.<\/h2>\n<p>As described on the <a title=\"Three or four column grid layouts\" href=\"https:\/\/blogs.ncl.ac.uk\/t4\/2014\/02\/26\/three-or-four-column-grid-layouts\/\">columns and grids and layout page<\/a>, these six boxes have been created using the\u00a0<a title=\"Three or four column grid layouts\" href=\"https:\/\/blogs.ncl.ac.uk\/t4\/2014\/02\/26\/three-or-four-column-grid-layouts\/\">threecol class<\/a>. Each box is its own piece of content within that section:<\/p>\n<p><img decoding=\"async\" alt=\"rawhtml\" src=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/rawhtml-300x90.jpg\" \/><\/p>\n<p>Return to the\u00a0Styles for Homepage content type and add the following code above the closing &lt;\/style&gt; tag:<\/p>\n<p>.threecol<br \/>\n{<br \/>\nmargin-bottom:16px;<br \/>\n}<br \/>\n.threecol p, .threecol img<br \/>\n{<br \/>\nmargin:0px !important;<br \/>\npadding:0px !important;<br \/>\n}<br \/>\n.threecol h4<br \/>\n{<br \/>\nmargin:0px !important;<br \/>\npadding: 5px !important;<br \/>\nbackground-color:darkblue;<br \/>\ncolor:white;<br \/>\n}<br \/>\n.threecol a<br \/>\n{<br \/>\ncolor:white;<br \/>\n}<\/p>\n<p>All of the above adds new styling rules to any content contained in boxes with the class threecol. Classes are referred to in CSS using a full stop, so we <a href=\"http:\/\/www.w3schools.com\/css\/css_selectors.asp\">apply style rules<\/a> to our threecol content using <em>.threecol<\/em>.<\/p>\n<ul>\n<li>The first <em style=\"color: #000000\">margin-bottom:16px<\/em>; makes sure that the boxes are separated from each other.<\/li>\n<li><em style=\"color: #000000\">margin:0px !important;<\/em> and\u00a0<em style=\"color: #000000\">padding:0px !important;<\/em> remove any existing <a style=\"font-style: normal\" href=\"http:\/\/www.w3schools.com\/css\/css_padding.asp\">padding<\/a> or <a style=\"font-style: normal\" href=\"http:\/\/www.w3schools.com\/css\/css_margin.asp\">margin <\/a>styles from the images (img) or paragraphs (p) within the threecol boxes.<\/li>\n<li>The links are within header level 4, so the next bit (beginning <em style=\"color: #000000\">.threecol h4<\/em>)\u00a0targets them and gives them a <a style=\"font-style: normal\" href=\"http:\/\/www.w3schools.com\/tags\/ref_colornames.asp\">dark blue background<\/a> and white text colour.<\/li>\n<li>Finally, <em style=\"color: #000000\">.threecol<\/em> a (stands for <a href=\"http:\/\/www.w3schools.com\/tags\/tag_a.asp\">anchor<\/a>) refers to the link text colour: it&#8217;s going to be white.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/css-classes.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-365\" alt=\"css classes\" src=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/css-classes-300x224.png\" width=\"300\" height=\"224\" srcset=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/css-classes-300x224.png 300w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/css-classes-1024x766.png 1024w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/css-classes-400x300.png 400w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/css-classes.png 1263w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Previewing the page, it now looks like this:<\/p>\n<p><a href=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-Boxed-Newcastle-University.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-366\" alt=\"Years Ahead Boxed  Newcastle University\" src=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-Boxed-Newcastle-University-300x233.png\" width=\"300\" height=\"233\" srcset=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-Boxed-Newcastle-University-300x233.png 300w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-Boxed-Newcastle-University-384x300.png 384w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Years-Ahead-Boxed-Newcastle-University.png 1020w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>3: Updating the Styling on the Navigation Bar<\/h2>\n<p>The navigation bar across the top has an ID:\u00a0top-nav. ID&#8217;s are selected using a # symbol, so we can apply rules to it using #top-nav.<\/p>\n<p>Since we want these CSS rules to apply to the whole site, not just the homepage, we should put them in the section styles folder, which contains a piece of content called &#8216;template scheme&#8217;.<\/p>\n<p><a href=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/templatescheme.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-367\" alt=\"templatescheme\" src=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/templatescheme-300x85.png\" width=\"300\" height=\"85\" srcset=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/templatescheme-300x85.png 300w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/templatescheme-1024x290.png 1024w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/templatescheme-1000x288.png 1000w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/templatescheme-500x142.png 500w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/templatescheme.png 1063w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>The template scheme content contains the facility to choose colours and upload an image for the sites top banner, but for now we&#8217;re interested in the final\u00a0Custom CSS field. Add the following code to this field.<\/p>\n<p>#top-nav a:hover<br \/>\n{<br \/>\ncolor:white !important;<br \/>\n}<\/p>\n<p><a href=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Custom-CSS.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-368\" alt=\"Custom CSS\" src=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Custom-CSS-300x224.png\" width=\"300\" height=\"224\" srcset=\"https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Custom-CSS-300x224.png 300w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Custom-CSS-1024x766.png 1024w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Custom-CSS-400x300.png 400w, https:\/\/blogs.ncl.ac.uk\/t4\/files\/2014\/05\/Custom-CSS.png 1263w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<ul>\n<li><strong>#topnav<\/strong> targets the ID of the navigation bar.<\/li>\n<li><strong>a<\/strong> refers to the hyperlink (anchor)<\/li>\n<li><a href=\"http:\/\/www.w3schools.com\/cssref\/sel_hover.asp\"><strong>:hover<\/strong><\/a> refers to the state of the link when a mouse is hovering over it.<\/li>\n<\/ul>\n<p>Update and Approve the content. Because this style rule refers to the entire site, not just a single page, preview won&#8217;t work and you may have to wait until the entire site publishes to see the results.<\/p>\n<ul>\n<li>For further information, please consult tie W3schools pages on CSS:\u00a0<a style=\"font-style: normal\" href=\"http:\/\/www.w3schools.com\/css\/default.asp\">http:\/\/www.w3schools.com\/css\/default.asp<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Content on webpages is described using HTML and the layout and look of it can be styled using a language called CSS: Cascading Style Sheets. HTML and CSS is largely out of scope for this blog, as it&#8217;s well described &hellip; <a href=\"https:\/\/blogs.ncl.ac.uk\/t4\/2014\/05\/21\/styling-content-using-html-and-css\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":839,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-360","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.ncl.ac.uk\/t4\/wp-json\/wp\/v2\/posts\/360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ncl.ac.uk\/t4\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.ncl.ac.uk\/t4\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/t4\/wp-json\/wp\/v2\/users\/839"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/t4\/wp-json\/wp\/v2\/comments?post=360"}],"version-history":[{"count":1,"href":"https:\/\/blogs.ncl.ac.uk\/t4\/wp-json\/wp\/v2\/posts\/360\/revisions"}],"predecessor-version":[{"id":369,"href":"https:\/\/blogs.ncl.ac.uk\/t4\/wp-json\/wp\/v2\/posts\/360\/revisions\/369"}],"wp:attachment":[{"href":"https:\/\/blogs.ncl.ac.uk\/t4\/wp-json\/wp\/v2\/media?parent=360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/t4\/wp-json\/wp\/v2\/categories?post=360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.ncl.ac.uk\/t4\/wp-json\/wp\/v2\/tags?post=360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}