![Introduction to HTML](images/webdev101-html.png)
> Sketchnote by [Tomomi Imura](https://twitter.com/girlie_mac)
## Pre-Lecture Quiz
## 강의 전 퀴즈
[Pre-lecture quiz](.github/pre-lecture-quiz.md)
### Introduction
### 소개
HTML, or HyperText Markup Language, is the 'skeleton' of the web. If CSS 'dresses up' your HTML and JavaScript brings it to life, HTML is the body of your web application. HTML's syntax even reflects that idea, as it includes "head", "body", and "footer" tags.
In this lesson, we're going to use HTML to layout the 'skeleton' of our virtual terrarium's interface. It will have a title and three columns: a right and a left column where the draggable plants live, and a center area that will be the actual glass-looking terrarium. By the end of this lesson, you will be able to see the plants in the columns, but the interface will look a little strange; don't worry, in the next section you will add CSS styles to the interface to make it look better.
### Task
### 작업
On your computer, create a folder called 'terrarium' and inside it, a file called 'index.html'. You can do this in Visual Studio Code after you create your terrarium folder by opening a new VS Code window, clicking 'open folder', and navigating to your new folder. Click the small 'file' button in the Explorer pane and create the new file:
@ -31,7 +31,7 @@ Use these commands on your git bash:
---
## The DocType and html tags
## DocType과 html 태그
The first line of an HTML file is its doctype. It's a little surprising that you need to have this line at the very top of the file, but it tells older browsers that the browser needs to render the page in a standard mode, following the current html specification.
@ -39,7 +39,7 @@ The first line of an HTML file is its doctype. It's a little surprising that you
The second line should be the `<html>` tag's opening tag, followed right now by its closing tag `</html>`. These tags are the root elements of your interface.
### Task
### 작업
Add these lines at the top of your `index.html` file:
@ -52,7 +52,7 @@ Add these lines at the top of your `index.html` file:
---
## The document's 'head'
## 문서의 'head'
The 'head' area of the HTML document includes crucial information about your web page, also known as [metadata](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta). In our case, we tell the web server to which this page will be sent to be rendered, these four things:
@ -62,7 +62,7 @@ The 'head' area of the HTML document includes crucial information about your web
- browser information, including `x-ua-compatible` which indicates that the IE=edge browser is supported
- information about how the viewport should behave when it is loaded. Setting the viewport to have an initial scale of 1 controls the zoom level when the page is first loaded.
### Task
### 작업
Add a 'head' block to your document in between the opening and closing `<html>` tags.
@ -79,13 +79,13 @@ Add a 'head' block to your document in between the opening and closing `<html>`
---
## The document's`body`
## 문서의`body`
### HTML Tags
In HTML, you add tags to your .html file to create elements of a web page. Each tag usually has an opening and closing tag, like this: `<p>hello</p>` to indicate a paragraph. Create your interface's body by adding a set of `<body>` tags inside the `<html>` tag pair; your markup now looks like this:
### Task
### 작업
```html
<!DOCTYPE html>
@ -102,13 +102,13 @@ In HTML, you add tags to your .html file to create elements of a web page. Each
Now, you can start building out your page. Normally, you use `<div>` tags to create the separate elements in a page. We'll create a series of `<div>` elements which will contain images.
### Images
### 이미지
One html tag that doesn't need a closing tag is the `<img>` tag, because it has a `src` element that contains all the information the page needs to render the item.
Create a folder in your app called `images` and in that, add all the images in the [source code folder](../images); (there are 14 images of plants).
### Task
### 작업
Add those plant images into two columns between the `<body></body>` tags:
@ -173,7 +173,7 @@ Each image has an alt tag that will appear even if you can't see or render an im
---
## Semantic markup
## 시멘틱 마크업
In general, it's preferable to use 'semantics' when writing HTML. What does that mean? It means that you use HTML tags the way they were designed: to represent its data; so an H1 tag should always be present on a page
@ -187,11 +187,11 @@ Using semantic markup such as having headers be `<h1>` and unordered lists be re
✅ Take a look at a screen reader and [how it interacts with a web page](https://www.youtube.com/watch?v=OUDV1gqs9GA). Can you see why having non semantic markup might confuse the user?
## The terrarium
## terrarium
The last part of this interface involves creating markup that will be styled to create a terrarium.
### Task:
### 작업:
Add this markup above the last `</div>` tag:
@ -211,21 +211,21 @@ Add this markup above the last `</div>` tag:
---
## 🚀Challenge
## 🚀 도전
There are some wild 'older' tags in HTML that are still fun to play with, though you shouldn't use deprecated tags such as [these tags](https://developer.mozilla.org/en-US/docs/Web/HTML/Element) in your markup. Still, can you use the old `<marquee>` tag to make the h1 title scroll horizontally? (if you do, don't forget to remove it afterwards)
## Post-Lecture Quiz
## 강의 후 퀴즈
[Post-lecture quiz](.github/post-lecture-quiz.md)
## Review & Self Study
## 리뷰 & 자기주도 학습
HTML is the 'tried and true' building block system that has helped build the web into what it is today. Learn a little about its history by studying some old and new tags. Can you figure out why some tags were deprecated and some added? What tags might be introduced in the future?
Learn more about building sites for the web and mobile devices at [Microsoft Learn](https://docs.microsoft.com/learn/modules/build-simple-website/?WT.mc_id=cxaall-4621-cxall).
## Assignment
## 과제
[Practice your HTML: Build a blog mockup](assignment.md)
> Sketchnote by [Tomomi Imura](https://twitter.com/girlie_mac)
## Pre-Lecture Quiz
## 강의 전 퀴즈
[Pre-lecture quiz](.github/pre-lecture-quiz.md)
### Introduction
### 소개
CSS, or Cascading Style Sheets, solve an important problem of web development: how to make your web site look nice. Styling your apps makes them more usable and nicer-looking; you can also use CSS to create Responsive Web Design (RWD) - allowing your apps to look good no matter what screen size they are displayed on. CSS is not only about making your app look nice; its spec includes animations and transforms that can enable sophisticated interactions for your apps. The CSS Working Group helps maintain current CSS specifications; you can follow their work at [World Wide Web Consortium's site](https://www.w3.org/Style/CSS/members).
@ -15,11 +15,11 @@ CSS, or Cascading Style Sheets, solve an important problem of web development: h
In this lesson, we're going to add styles to our online terrarium and learn more about several CSS concepts: the cascade, inheritance, and the use of selectors, positioning, and using CSS to build layouts. In the process we will layout the terrarium and create the actual terrarium itself.
### Prequisite
### 준비물
You should have the HTML for your terrarium built and ready to be styled.
### Task
### 작업
In your terrarium folder, create a new file called `style.css`. Import that file in the `<head>` section:
@ -29,11 +29,11 @@ In your terrarium folder, create a new file called `style.css`. Import that file
---
## The Cascade
## Cascade
Cascading Style Sheets incorporate the idea that the styles 'cascade' such that the application of a style is guided by its priority. Styles set by a web site author take priority over those set by a browser. Styles set 'inline' take priority over those set in an external style sheet.
### Task
### 작업
Add the inline style "color: red" to your `<h1>` tag:
@ -53,11 +53,11 @@ h1 {
---
## Inheritance
## 상속
Styles are inherited from an ancestor style to a descendent, such that nested elements inherit the styles of their parents.
### Task
### 작업
Set the body's font to a given font, and check to see a nested element's font:
@ -75,9 +75,9 @@ Open your browser's console to the 'Elements' tab and observe the H1's font. It
---
## CSS Selectors
## CSS 선택자
### Tags
### 태그
So far, your `style.css` file has only a few tags styled, and the app looks pretty strange:
@ -94,7 +94,7 @@ h1 {
This way of styling a tag gives you control over unique elements, but you need to control the styles of many plants in your terrarium. To do that, you need to leverage CSS selectors.
### Ids
### Id
Add some style to layout the left and right containers. Since there is only one left container and only one right container, they are given ids in the markup. To style them, use `#`:
@ -128,7 +128,7 @@ Here, you have placed these containers with absolute positioning to the far left
<divid="left-container"class="container"></div>
```
### Classes
### 클래스
In the example above, you styled two unique elements on the screen. If you want styles to apply to many elements on the screen, you can use CSS classes. Do this to layout the plants in the left and right containers.
@ -169,7 +169,7 @@ Also notable is the use of z-index, which controls the relative altitude of an e
✅ Why do you need both a plant holder and a plant CSS selector?
## CSS Positioning
## CSS 포지셔닝
Mixing position properties (there are static, relative, fixed, absolute, and sticky positions) can be a little tricky, but when done properly it gives you good control over the elements on your pages.
@ -183,7 +183,7 @@ In our sample, the `plant-holder` is a relative-positioned element that is posit
✅ Experiment with switching the types of positioning of the side containers and the plant-holder. What happens?
## CSS Layouts
## CSS 레이아웃
Now you will use what you learned to build the terrarium itself, all using CSS!
@ -242,7 +242,7 @@ Note the use of percentages here, even for the `border-radius`. If you scale you
---
## 🚀Challenge
## 🚀 도전
Add a 'bubble' shine to the left bottom area of the jar to make it look more glasslike. You will be styling the `.jar-glossy-long` and `.jar-glossy-short` to look like a reflected shine. Here's how it would look:
@ -250,14 +250,14 @@ Add a 'bubble' shine to the left bottom area of the jar to make it look more gla
To complete the post-lecture quiz, go through this Learn module: [Style your HTML app with CSS](https://docs.microsoft.com/en-us/learn/modules/build-simple-website/4-css-basics)
## Post-Lecture Quiz
## 강의 후 퀴즈
[Post-lecture quiz](.github/post-lecture-quiz.md)
## Review & Self Study
## 리뷰 & 자기주도 학습
CSS seems deceptively straightforward, but there are many challenges when trying to style an app perfectly for all browsers and all screen sizes. CSS-Grid and Flexbox are tools that have been developed to make the job a little more structured and more reliable. Learn about these tools by playing [Flexbox Froggy](https://flexboxfroggy.com/) and [Grid Garden](https://codepip.com/games/grid-garden/).
# Terrarium Project Part 3: DOM Manipulation and a Closure
# Terrarium 프로젝트 파트 3: DOM 조작과 클로저
![DOM and a closure](images/webdev101-js.png)
> Sketchnote by [Tomomi Imura](https://twitter.com/girlie_mac)
## Pre-Lecture Quiz
## 강의 전 퀴즈
[Pre-lecture quiz](.github/pre-lecture-quiz.md)
### Introduction
### 소개
Manipulating the DOM, or the "Document Object Model", is a key aspect of web development. According to [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction), "The Document Object Model (DOM) is the data representation of the objects that comprise the structure and content of a document on the web." The challenges around DOM manipulation on the web have often been the impetus behind using JavaScript frameworks instead of vanilla JavaScript to manage the DOM, but we will manage on our own!
@ -23,11 +23,11 @@ We will use a closure to manipulate the DOM.
In this lesson, we will complete our interactive terrarium project by creating the JavaScript that will allow a user to manipulate the plants on the page.
### Prequisite
### 준비물
You should have the HTML and CSS for your terrarium built. By the end of this lesson you will be able to move the plants into and out of the terrarium by dragging them.
### Task
### 작업
In your terrarium folder, create a new file called `script.js`. Import that file in the `<head>` section:
@ -38,11 +38,11 @@ In your terrarium folder, create a new file called `script.js`. Import that file
> Note: use `defer` when importing an external JavaScript file into the html file so as to allow the JavaScript to execute only after the HTML file has been fully loaded. You could also use the `async` attribute, which allows the script to execute while the HTML file is parsing, but in our case, it's important to have the HTML elements fully available for dragging before we allow the drag script to be executed.
---
## The DOM elements
## DOM 요소
The first thing you need to do is to create references to the elements that you want to manipulate in the DOM. In our case, they are the 14 plants currently waiting in the side bars.
### Task
### 작업
```html
dragElement(document.getElementById('plant1'));
@ -67,7 +67,7 @@ What's going on here? You are referencing the document and looking through its D
---
## The Closure
## 클로저
Now you are ready to create the dragElement closure, which is an outer function that encloses an inner function or functions (in our case, we will have three).
@ -89,7 +89,7 @@ In this example, the displayCandy function surrounds a function that pushes a ne
✅ How can you make the `candy` array accessible? Try moving it outside the closure. This way, the array becomes global, rather than remaining only available to the closure's local scope.
### Task
### 작업
Under the element declarations in `script.js`, create a function:
@ -112,11 +112,11 @@ In addition, the terrariumElement that is passed to this function is assigned a
---
## The Pointerdrag function
## Pointerdrag 함수
The terrariumElement is ready to be dragged around; when the `onpointerdown` event is fired, the function pointerDrag is invoked. Add that function right under this line: `terrariumElement.onpointerdown = pointerDrag;`:
Now you are indicating that you want the plant to be dragged along with the pointer as you move it, and for the dragging gesture to stop when you deselect the plant. `onpointermove` and `onpointerup` are all parts of the same API as `onpointerdown`. The interface will throw errors now as you have not yet defined the `elementDrag` and the `stopElementDrag` functions, so build those out next.
## The elementDrag and stopElementDrag functions
## elementDrag와 stopElementDrag 함수
You will complete your closure by adding two more internal functions that will handle what happens when you drag a plant and stop dragging it. The behavior you want is that you can drag any plant at any time and place it anywhere on the screen. This interface is quite un-opinionated (there is no drop zone for example) to allow you to design your terrarium exactly as you like it by adding, removing, and repositioning plants.
### Task
### 작업
Add the `elementDrag` function right after the closing curly bracket of `pointerDrag`:
@ -172,7 +172,7 @@ As you drag, you reassign `pos1` by making it equal to `pos3` (which you set ear
All this recalculation of positioning allows you to fine-tune the behavior of the terrarium and its plants.
### Task
### 작업
The final task to complete the interface is to add the `closeElementDrag` function after the closing curly bracket of `elementDrag`:
@ -193,15 +193,15 @@ Now you have completed your project!
---
## 🚀Challenge
## 🚀 도전
Add new event handler to your closure to do something more to the plants; for example, double-click a plant to bring it to the front. Get creative!
## Post-Lecture Quiz
## 강의 후 퀴즈
[Post-lecture quiz](.github/post-lecture-quiz.md)
## Review & Self Study
## 리뷰 & 자기주도 학습
While dragging elements around the screen seems trivial, there are many ways to do this and many pitfalls, depending on the effect you seek. In fact, there is an entire [drag and drop API](https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API) that you can try. We didn't use it in this module because the effect we wanted was somewhat different, but try this API on your own project and see what you can achieve.
@ -209,7 +209,7 @@ Find more information on pointer events on the [W3C docs](https://www.w3.org/TR/
Always check browser capabilities using [CanIUse.com](https://caniuse.com/).