GD2-AW03 – Images and Layout with CSS

LT. 3.1 Styling Images

The Task

You need to create an HTML and CSS document for this lesson task. Use one root folder containing separate CSS and image folders. Find three images you can use; one will be used as a background and one as part of the content, while the third should be a simple png with a transparent background.

Link the styles.css file with the HTML document using the property inside the section of the HTML document.

Part 1

Create a basic structure for the HTML document with a <body> containing a <header>, <main> and <footer> section. Insert a <h1> element into the <header> section and a <p> element with text inside the <main> section.

Using CSS, apply the following to the HTML page:

  • A background image for the <body> section;

  • A solid colour background for the <header> section, but with an opacity rule applied so that the background image is slightly visible behind the <header> container.
 
Once you have the background image showing, apply different values to the background properties that will produce the following results:

  • A repeated pattern of the background image using the properties “background-repeat” and “background-size”.
  • Place the background image in the centre of the screen using the properties “background-position”,; “background-size”, and “background-repeat”.
  • A full-page background image that fills the screen using “background-repeat” and “background-size” (remember that size can have specific values in % or px, but it can also have relative values like “contain” and “cover”).

Take screenshots of the HTML and CSS code as well as the browser results. Write a short description explaining how the property values changed the behaviour of the background image. This should be loaded onto your blog.

Part 2

Insert a div with a class into the <main> section of the HTML page. Specify the div’s size using a CSS rule that includes a height and width property. You can also specify a border so you can see the empty container. If you need to refresh your memory on border styles, visit this link.

Once the empty container is showing up in the browser or result view, add a multi-layered background to the container that includes the following:

  • A gradient;

  • A pattern made up of the png image you collected earlier.

Take screenshots of the CSS code and the result and write a short description explaining how the property values changed the behaviour of the background image.

Part 3

Insert two images in the <main> section using the <a> property in the HTML code. Using CSS, do the following:
 
  • Apply a border radius property to the first image;

  • Apply a pseudo-class property to the second image that reduces the opacity on hover.

Take screenshots of the HTML and CSS code as well as the browser results to load onto your blog.

LT. 3.2 Layout Elements

The task
You need to create an HTML and CSS document for this lesson task. Link the CSS file with the HTML document using the property inside the section of the HTML document.

Part 1

Copy this basic structure into the body of the HTML document and indent the code so that it shows the nested relationship of the content:
 
<header>
<nav>
<ul>
<li><a>home</a></li>
<li><a>about</a></li>
<li><a>contact</a></li>
</ul>
</nav>
</header>

<main>
<section>
<h1>Welcome Home</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna 
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
 aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint 
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</section>
</main>

Part 2

Using what you’ve learned so far, try to recreate the following browser display using CSS to style the above HTML:
Here’s a list of things that should be included in the HTML/CSS:
  • Classes;
  • Inline block display;
  • Margin properties;
  • Padding properties;
  • Font family;
  • Background colour properties;
  • Border properties;
  • Pseudo-class for the hover effect on the navigation menu.

LT. 3.3 – Styling Layout

The task
Download the exercise files containing the basic HTML document, logo and photograph. You will have to create a CSS document for this lesson task. Use one root folder to save the HTML file, and use separate CSS and image folders. Link the stylesheet to the HTML document using the link attribute in the <head> of the HTML document.
 

Goal

Look at this layout for a fictitious website advertising web development courses. Use what you have learnt to create the same layout (or as close to this as possible):

Part 1

First, examine the layout and draw a wireframe showing the different sections of the page. Then, inspect the HTML code to find the hierarchy of parent and child elements that respond to the sections you identified. Write down the names of the classes of the parent containers that make up the basic structure.

For example: <nav> is the parent container that holds two siblings: the logo image and the <ul> that make up the navigation menu. The <ul> element is the parent container that holds the three list items: Home, About and Contact.

 
 
 

Part 2

Start styling the different sections by assigning rulesets to the existing classes. Here are some tips you might find helpful:
  • The body element, by default, has some margin around the edges. To remove the margin, set it to 0%.
  • Flex was used to style the <nav> element as well as the first hero image section.
  • To get the elements within a flex container to align to the left and right sides of the window with space between, use the CSS rule “justify-content: space-between”.
  • Remember, padding creates spacing within an element (between the border and the content), while margin creates space between elements (outside the element’s border).
  • To align elements within a flex container right, use “justify-content: flex-end”.
  • Grid was used to style the information section below the image.
  • Position was used to create the footer.
Here is the CSS file to show you how we solved the above layout.
Take screenshots of your result. Write a short summary about how well you think you could redo the example website. Comment on what you’ve learnt.

LT. 3.4 – Media queries and code conventions

The task
For this lesson task, you’ll continue to work on the website you styled for SBD (fictitious website for web development courses) from the previous lesson task.
 

Goal

Using what you’ve learnt, add media queries to the stylesheet that will adjust the layout of the website to look like this on a mobile device:

Take a screenshot of your browser display and your HTML and CSS documents. Here is the updated CSS file with media queries to show you how we solved it. Compare this example to your own.

GD2-AW02 – CSS Basic

LT. 2.1 CSS Basic

A Nordic non-profit organisation commissions you to create a website to promote mental health awareness. This is a fictitious client.

Part 1

Create a basic file structure to organise your different types of documents and images.
Create at least three HTML pages for the project and name the home page index.html. Each HTML file should have the following:
 
  • A <head> section with an appropriate title and meta description.
  • A <body> section divided into a <header>, <main> and <footer> section.
  • Every page <header> must have a <ul> that contains links to all the HTML pages and a <h1> element that names the page.
     
The home page (or index.html) should also have a <main> element that contains the following sections:
 
  • What is mental health?
    This section should have at least one <p> element with text (you can use placeholder text).
  • What are the warning signs?
    This section should include a list (you can decide to use a <ul> or <ol>).
  • What to do?
    This section should include a <p> element with at least one link to an outside source using the <a> element.
Remember to make use of semantic <H1>, <H2> and <p> elements to organise the body text, headings and subheadings on the page.

Part 2

Create a new document in Adobe Dreamweaver. This time, choose “CSS” as your document type. A window with source code will open. Save the file as “styles.css” in the same root folder as the index.html file and close it.

Go back to the source code of the index.html file and link the styles.css file to the index.html file. You should add all the information inside the <link> tag using attributes. Remember, a link element is one of the elements that does not require an opening and closing tag.

Part 3

Using your existing index.html document, give a unique ID to one of the sections in your document and give a class to one of the <p>, <ul> or <ol> elements.

Now open the CSS file and create a ruleset that targets each the following elements inside the HTML document:

 
  • The <h1> element;
  • The section with the unique ID;
  • The <p>, <ul> or <ol> element with a class assigned to it.

LT. 2.2 CSS Implementation And Inheritance

Part 1

Using what you’ve learned about general and more specific styling, apply a style to all text inside the <body> of the html document. You can use any property, but some suggestions are different web-safe fonts like in the lesson example, a text-decoration, font style or a colour property.

Using a descendant selector, specify a different style for the links inside the list items of the navigation. Test to see if the link items render differently than the general body text in the browser or result view.

Take screenshots of the HTML, CSS and browser or result view and describe what you’ve learned.

Since we actually have been through this basic HTML and CSS the first year I feel that until now it’s just a refresh on what I learned the first time we were going through this. But again I feel like this modul is a bit deeper in to the basic. So to be honest I haven’t learnt that much more out of this but I feel it was a really nice refreshing.

Part 2

Open the website CSS Zen Garden in Chrome. This website was developed to display how powerful CSS can change the appearance of a simple HTML document.

Using the Chrome inspect function, find the following elements:

  • <h1>
  • <p>
  • A link <a> with the class=”designer-name” inside a <li> element.

For each element, write down the CSS ruleset applied to it (you will see this in the styles pane). After doing this, load a different CSS style to the webpage and repeat the exercise.

Write about how the appearance of each of the three elements changed from one CSS ruleset to the other and mention what properties and values were applied. You can include screenshots to support your writing.

h1 {
padding-top: 0;
padding-bottom: 5px;
border-bottom: none;
font-family: ‘Julius Sans One’, sans-serif;
font-size: 3.2em;
text-transform: uppercase;
}

p {
display: block;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
}

a.designer-name {
color: #616857;
font-size: 0.9em;
font-style: normal;
}

h1 {
position: fixed;
left: -.3em;
top: 0;
width: 1em;
font-size: 48px;
line-height: .8;
text-align: center;
text-transform: uppercase;
word-wrap: break-word;
text-shadow: 0 0 48px rgba(0,0,0,0.3);
webkit-transition: all 0.2s ease-out;
moz-transition: all 0.2s ease-out;
ms-transition: all 0.2s ease-out;
o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}

p {
display: block;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
}

a.designer-name {
font-family: ‘Montserrat’, Verdana, Helvetica, Arial, sans-serif;
font-weight: bold;
font-style: normal;
font-size: .875em;
text-decoration: none;
text-transform: uppercase;
}

LT. 2.3 Styling Text

Question 1

Use an online font library and select a font pair for your project. You need to choose one font to use as a heading font and a different font to use for all paragraph or body text. We recommend Google fonts, but you can use a different library if you want to. 

Using the <link> tag method described in the lesson, link the chosen fonts into your project. Create rules in CSS to apply the fonts from the library to create a different font style for headings, paragraph text and list items. The same text styles should apply to all the pages of your website. 

Take screenshots of the HTML, CSS and browser or result view. If you encounter any problems, try to go over the lessons on inheritance and styling text. Write a short paragraph to explain what you have learned about styling text using fonts from an online font library. 

As I mention in one of the last tasks I feel that I already knew this from earlier. But it’s still nice to go through it again.

LT. 2.4 Pseudo-Classes

Part 1

For this lesson task, you need to focus on applying pseudo-classes to the navigation list. Apply a “hover” and “active” state to all the menu items. The styling can be as simple as a background colour, font style or text-decoration.

The hover style must show when you hover over the link with your mouse, and the active state must show on the link when you are on that particular page. For example, the “contact” link in the navigation list must look different to the rest of the links when you are on the contact page.

Part 2

It’s time to put the links to the test from outside your local folder. Upload the root folder containing all your web page files to your host using an FTP client. Once uploaded, check if the fonts load correctly on all pages, check the images and pseudo-classes and check if your page links work properly.

Take screenshots to show your web page loads correctly in the Google Chrome browser. Upload the screenshots with a short description of the process to your blog. If you had to fix any links, remember to also write about your problem-solving.

The website is working.

GD2-AW01 – HTML Basics

LT. 1.1 Hosting And File Management

Part 1

Since you will create your own website using HTML and CSS in this course, you will need to acquire your own hosting service. This part of the lesson task is mandatory.

You are free to choose any hosting service, but we recommend one.com. The monthly fee is low, and the beginner plan is sufficient.

Consider your domain name very carefully. This cannot be altered. You will be able to use this domain for future website projects. (You can, of course, sign up for other domain names and delete the one you have, but “getting it right the first time” saves you a great deal of trouble.)

I already have hosting at one.com, for my portfolio and my reflective journal. I’m going to move my reflective journal from www.tinahetland.com to www.myreflectivejournal.hetiart.no as soon as I have some time to do it. The reason for this is because I want to use www.tinahetland.com for my photography portfolio again.

Part 2

The Norwegian Seafood Council wants to promote the health benefits of Norwegian salmon to the local and international market. You need to create an informative website for this purpose. (This is a fictitious client and project).

Create very basic wireframes for the website, showing at least three pages. These can be low tech wireframes that show planning for the page structure and navigation.

The Norwegian Seafood Council Wireframe

Part 3

Create the structure for the HTML files and folders of the web page. Think about the root folder and name the folders correctly. Firstly, sketch out what the structure will look like. Then, set these up, so you are ready to code your website.

Open Adobe Dreamweaver. Click on the ‘Create New’ button, and under ‘Document type’, choose HTML. Keep the ‘Framework’ as none since we will not use a Bootstrap framework. You can give the file a name, call it ‘home’ and the ‘Doc Type’ should be HTML5.

This will open a blank document in Dreamweaver. You will see a tab called ‘Untitled-1’ in the top left bar. This is because the file is not yet saved. Hit ‘save’ and save the file as Index.html in the correct folder of the folder structure you created. One HTML document called ‘index.html’ is enough for this LT.

Remember, this structure should be set up so that it can be uploaded to a hosting server without disrupting the file paths. When you are done, take a screenshot of the folder and, together with the sketch of your structure, upload it to your WordPress blog.

The Norwegian Seafood Council Structure

LT. 1.2 HTML Basic

For this lesson task, you need to create a basic HTML structure.

Part 1

  • In Adobe Dreamweaver, open up the index.html file you created in the previous lesson task. If you do not have one, then create a new document now.
  • Make sure the HTML file is saved as index.html in the folder structure you created for the lesson task on planning the structure. Note that the tile of the page can be different from the file’s name. You always need to name at least one file index.html, as a browser will look for such a file to load first. It does not have to be your home page, but this is standard practice.
  • Now, start adding some tags. It is perfectly fine if you don’t add any information between the opening and closing tags for now, just focus on the different tags that will make up the structure of the webpage. Your HTML file should have the following content:
    • <!DOCTYPE html> – this should be the first line in the document.
    • <html><head> and <body> elements.
    • Page title – note: the <title> element must sit within the <head> element.
    • <header><main> and <footer> elements, these must sit within the <body> element.

Almost all of the elements you will use have opening and closing tags. Typical “newbie” mistakes include forgetting to close your tags. Check your work!

Take a screenshot of the HTML coded document to post to your blog.

Basic HTML Structure

Part 2

You have created an HTML document with the following content:
  • <!DOCTYPE html>
  • <html>
  • <head>
  • <body>
  • <title>
  • <header>
  • <main>
  • <footer>
In one or two sentences, describe the function and meaning of each element and, where applicable, state in which parent folder you are expected to find the element.

Description And Meaning

<!DOCTYPE html> : The first line of the document that indicate what document it is.

<html> : The <html> tag is the main “nest container” where all of the elements are put in to.

<head> : The <head> tag contains metadata and information about the page, this will not be visible on the website.

<meta> : The <meta> tag always go inside the <head> element and are typically used to specify the data of the page, like page description, keywords, author and viewport settings.

<title> :  The <title> tag is required in a HTML document, it defines the title of the document. This title is shown in the browsers title bar or in the pages tab. This tag needs to be inside the <head> tag.

<body> : The <body> tag defines the document’s body, it contains all the elements of an HTML document as headings, paragraphs, images, nav, tables, lists, footer, etc. And there can only be one <body> element in the document.

<header> : The <header> tag represents the container for introductory content or a set of navigational linkes. This tag needs to be inside the <body> tag.

<nav> : The <nav> tag defines a set of navigation links, the <nav> element is intended only for  major blocks of navigation links. This tag needs to be inside the <body> tag.

<main> : The <main> tag specifies the main content of the document. This tag needs to be inside the <body> tag.

<footer> : The <footer> tag is the last element inside the <body> tag, and are placed at the bottom of the page. This can contain many elements but typically contains authorship, copyright, contact information, related documents, back to top links, etc.

LT. 1.3 Semantic HTML

For this lesson task, you’ll be working on the same HTML document you created in the previous lesson task, “Creating an HTML structure”.

Part 1

The following elements should now be added to the HTML document:
  • <meta> element with some metadata – charset, description, keywords, author, viewport – note: must sit within the <head> element.
  • Create a <ul> (unordered list) with <li> elements that will later form the navigation menu. (You are not required to style or link anything at this point, just list the menu items that will represent the links to the different pages of the website later). Think carefully about where you should place this list.
  • Create at least two sections in the content using either <section><article> or <aside> elements that will hold the main content.
  • Create at least one <h1> element, and one <h2> element. Note how the <h1> and <h2> elements render as different sizes, and as bold text.
  • Create at least four <p> elements.

Check your page in a web browser to make sure it works properly. Don’t be discouraged if the results are not overly impressive or if the page does not work as you expected. We will be quickly moving along to more complex and visually rich pages.

Post screenshots of the code and browser result to your WordPress blog.

LT. 1.4 HTML Links And Images

For this lesson task, you will continue to work on the web project to promote Norwegian salmon. You can use the same HTML document you’ve been working on in the previous two lesson tasks as a starting point. 

Part 1

Create the other HTML pages that you have planned for the webpage. (This should include all the pages that are on your <ul>). Take note of where you are saving these files in your file structure. 

Using the href=”” attribute and relative file paths, create links to each of the pages from the <ul> in the index.html document. 

Populate each of the new HTML files with the same <ul> for navigation and at least a <h1> header to state the title of the page.

Part 2

In your index.html document, add one image to one of the sections in the page using a relative file path. Note that you need to take special care of where you put the image in the folder structure and how you link the href. Add text for the alt attribute. This should describe the image in some way if it’s not displayed.

You can experiment by adding a width or height attribute to make the image fit inside the browser display.

Add another image. Observe how the images are placed on the HTML page. Add a <br> element between the images to see how the layout changes. Add an <hr> element to insert a line break between the images. Finally, add a <p> element between the images. 

Part 3

Select the root folder containing your HTML and the ‘Images’ folder and upload it to your host using an FTP client. Once uploaded, check if the remote files work in your browser. 

Check your page links in the live browser to see if it works properly. Check if the images display. If not, check your links and file locations.

Post screenshots of the code and browser result to your WordPress blog and write about what you have learned. 

I’ve uploaded the root folder in to file management at one.com and the page loads and look as it should. The linked also works.

We have been through all this coding earlier but I feel that now when we actually have to write the code ourself I understands it even better then I did earlier. When we made the CA05 and CA07 I used a lot of finished codes, bootstraps and snippets. So by actually write them myself is going to be a hard thing but so much better when it comes to actually learning it.