Difference between revisions of "Courses/Design & Technique-Essential Web Design/03"

From Publication Station
Line 1: Line 1:
<slidy theme="a"/>
=HTML div and span=
 
== <nowiki><div></nowiki> tag ===
The div tag is essentially a square container for other content.
 
<source lang="html4strict">
<div style="background:black; color:red; width:400px; height: 400px">                     
    <h1>Beautiful page</h1>                                                   
    <p>writing stuff                                                           
      <i>inside</i>                                                           
    </p>                                                                       
</div>
</source>
 
 
'''[https://chrome.google.com/webstore/detail/abstract-browsing/nmkbjeagaobhphiipgigbjhligebkfcg?hl=en-US Abstract Browsing]''' is a Chrome extension by [http://www.newrafael.com/ Rafaël Rozendaal] that transforms web pages into colored divs.
 
 
=== <nowiki> span</nowiki> tag ===
<source lang="html4strict">
<div style="background:black; color:red; width:400px; height: 400px">                     
    <h1>Beautiful page</h1>                                                   
    <p>writing stuff                                                           
      <i>inside</i>                                                           
    </p>                                                                       
</div>
</source>
 


=UTF-8 Encoding=
=UTF-8 Encoding=
Use more than [https://en.wikipedia.org/wiki/ASCII ASCII] characters by telling to the browser your page uses [https://en.wikipedia.org/wiki/UTF-8 UTF-8]  
Use more than [https://en.wikipedia.org/wiki/ASCII ASCII] characters by telling to the browser your page uses [https://en.wikipedia.org/wiki/UTF-8 UTF-8]
encoding scheme.
encoding scheme.


UTF-8 can represent any character in the [http://unicode-table.com/en/ Unicode table]
UTF-8 can represent any character in the [http://unicode-table.com/en/ Unicode table], including emoji, Chinese, Arabic, Greek, etc characters.


<source lang="html4strict">
<source lang="html4strict">
Line 11: Line 38:
<html>
<html>
  <head>
  <head>
        <meta charset="UTF-8" />
          <meta charset="UTF-8" />
  </head>
  <title>😹<</title>
</html>
    </head>
<body></body>
    </html>
</html>
    <body>
    <h1>😹<s page</h1>
            </body>
    </html>
</source>
</source>
-----


=Styling your page with CSS=
=Styling your page with CSS=


==CSS - Cascading Style Sheets ==  
==CSS - Cascading Style Sheets ==
HTML is not meant to style (inline syling: <code>style="color:..."</code> is old fashion and discouraged).
HTML is not meant to style (inline syling eg: <code><h1 style="color:red brackground:black></code> is old fashion and discouraged).


'''CSS is the preferred to way to style.'''
'''CSS is the preferred to way to style.'''
Line 27: Line 59:
* CSS tells the browser '''how to display''' that content.
* CSS tells the browser '''how to display''' that content.


==css inside an HTML page==
==CSS inside an HTML page==
* CSS code goes inside the style tags <code><style> ... </style></code>  
* CSS code goes '''inside the style tags''' <code><style> ... </style></code>
*  <code><style> ... </style></code> tags are placed inside the head of the HTML page.
*  <code><style> ... </style></code> tags are '''placed inside the head''' of the HTML page.


<source lang="html4strict">
<source lang="html4strict">
Line 35: Line 67:
<html>
<html>
  <head>
  <head>
  <style>
    <style>


     body{
     body{
      background: #FF19DC;
            background: #FF19DC;
      color: black;
    color: black;
      font-family: mono;
    font-family: mono;
      }  
        }


   </style>
   </style>
</head>
  </head>
</html>
  </html>
<body></body>
  <body></body>
</html>
  </html>
</source>
</source>


Line 53: Line 85:
Each CSS style sheet (all the styles of a page) is made of several rules.
Each CSS style sheet (all the styles of a page) is made of several rules.


Each '''rule''' follows the syntax:  
Each '''rule''' follows the syntax:
 
[[File:Basic-Anatomy-of-a-CSS-Rule1.png|600px|]]
[[File:Basic-Anatomy-of-a-CSS-Rule1.png|600px|]]


Line 72: Line 104:
       height: 250px;
       height: 250px;
       font-size:30pt;
       font-size:30pt;
  }
        }
</source>
</source>
Here we are styling all the div elements in the html page.
Here we are styling all the div elements in the html page.


Line 87: Line 120:
* [https://developer.mozilla.org/en-US/docs/Web/CSS/transform transform], gradient, border-radius
* [https://developer.mozilla.org/en-US/docs/Web/CSS/transform transform], gradient, border-radius


'''Use some of these properties to style your page.'''
'''Use some of these properties and others that you find out in your page.'''
 
 
= CSS position, display, float =
@andre: study and explain CSS position
https://kilianvalkhof.com/2008/css-xhtml/understanding-css-positioning-part-1/
http://learn.shayhowe.com/html-css/positioning-content/
 
== Position ==
 
* absolute
* relative
 
== Display ==
@andre: SEE display property explain in http://dustwell.com/div-span-inline-block.html http://stackoverflow.com/questions/9189810/css-display-inline-vs-inline-block
 
* none / hidden - turns to '''none''' (hides) the display of the element.
* inline - horizontal line of elements, but width and hide will be define by its content.
* block - vertical stack of elements.
* inline-block - horizontal line of elements, but they can have a width and height.
 
https://developer.mozilla.org/en-US/docs/Web/CSS/display
 




=id and class attributes=
=id and class attributes=
Two of the most used attributes in HTML is id and class.  
Two of the most used attributes in HTML is id and class.


They are important to distinguish and group different elements. And become particularly important in CSS styling.
They are important to distinguish and group different elements. And become particularly important in CSS styling.
Line 124: Line 134:
==id==
==id==
* '''id (#) is used to 'distinguish'' tags'''
* '''id (#) is used to 'distinguish'' tags'''
* the same id cannot be repeated in the same file. Use only once.  
* the same id cannot be repeated in the same file. Use only once.
* The symbol for id is: '''<code>#</code>'''
* The symbol for id is: '''<code>#</code>'''


<source lang="css">
<source lang="css">
p {color: black;
p {color: black;
   font-weight: bold;  
   font-weight: bold;
  }
      }


p#special{ color: red;
p#special{ color: red;
           font-weight: normal;  
           font-weight: normal;
           transform: matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
           transform: matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
}
      }
</source>
</source>


Line 147: Line 157:


==class==
==class==
* '''class (.)''' is used to ''group'' tags'''
* '''class (.)''' is used to ''group'' different tags''' - They become styled by same CSS rule
* class can be used INFINITE TIMES in a file
* class can be used INFINITE TIMES in a file
* The symbol for class is: <code>.</code>
* The symbol for class is: <code>.</code>
Line 157: Line 167:


.text{ color: black;
.text{ color: black;
           font-weight: italic ;  
           font-weight: italic ;
          background: #003366;
              background: #003366;
          color: white;
                color: white;
}
}
</source>
<source lang="html4strict">
<div class="text">This is a div tag</div>
<span class="text">This is a span tag</span>
<p class="text">and this is a p tag</p>
<p>Notice how all the above tags with class="text" are styled the same way.</p>
<p>These 2 last tags, on the other hand have NOT class="text", and therefore remain are not affected by the CSS rule</p>
<p>Also notice how 3 different tags can look the same if they share the same class </p>
</source>
</source>
== inspector ==
== a separate CSS file  ==
The CSS for a HTML page (or several pages) can stored outside that page, in '''css file.
To do that we need link the HTML file to the CSS file, using the tag link inside the html head.
<link href="style.css" rel="stylesheet" />
<source lang="html4strict">
<source lang="html4strict">
<div class="text">This is a div tag</div>                                                          
<!DOCTYPE html>
<span class="text">This is a span tag</span>                                                        
<html>
<p class="text">and this is a p tag</p>
<head>
<p>Notice how all the above tags with class="text" are styled the same way.</p>
  <link href="style.css" rel="stylesheet" />
<p>These 2 last tags, on the other hand have NOT class="text", and therefore remain are not affected by the CSS rule</p>
  </head>
<p>Also notice how 3 different tags can look the same if they share the same class </p> 
  <body>
  ....
</source>
</source>
 


==homework==
Apply CSS to the content of your weblog
* Make each entry (past or future) in your weblog will be wrapped inside a div
* Give each entry div an unique id; and a common class. E.g <code><div id="entry01" class="weblog">
....</div></code>*
* Style each entry differently
* ADD content




== Online Resources ==
== Online Resources on CSS ==
* CSS Property reference https://developer.mozilla.org/en-US/docs/Web/CSS/Reference
* CSS Property reference https://developer.mozilla.org/en-US/docs/Web/CSS/Reference
* Lynda.com CSS-Selectors (Part 1) http://www.lynda.com/CSS-tutorials/CSS-Selectors/192036-2.html?org=hr.nl
* Lynda.com CSS-Selectors (Part 1) http://www.lynda.com/CSS-tutorials/CSS-Selectors/192036-2.html?org=hr.nl
Line 180: Line 222:




==homework==
Apply CSS to the content of your weblog


* Make each entry (past or future) in your weblog will be wrapped inside a div
= Artistic use of CSS=
* Give each entry div an unique id; and a common class. E.g <code><div id="entry01" class="weblog">
Nan Wang Eyes:
....</div></code>*
 
* Style each entry differently
Book Scapes: http://www.julienlevesque.net/books-scapes/index2.html (advanced, maybe to when introduce CSS position )
* ADD content


@Andre: clarify .




==Next week==
------
Will be dedicated to CSS for typography; And web-fonts;


----
BOOK SCAPES: http://www.julienlevesque.net/books-scapes/index2.html




== a separate CSS file  ==
= CSS position, display, float =
  Move this to next class
  @andre: study and explain CSS position in next class
https://kilianvalkhof.com/2008/css-xhtml/understanding-css-positioning-part-1/
http://learn.shayhowe.com/html-css/positioning-content/


The CSS for a HTML page (or several pages) can stored outside that page, in '''css file.
== Position ==
* absolute
* relative


To do that we need link the HTML file to the CSS file, using the tag link inside the html head.  
== Display ==
@andre: SEE display property explain in http://dustwell.com/div-span-inline-block.html http://stackoverflow.com/questions/9189810/css-display-inline-vs-inline-block


<link href="style.css" rel="stylesheet" />
* none / hidden - turns to '''none''' (hides) the display of the element.
* inline - horizontal line of elements, but width and hide will be define by its content.
* block - vertical stack of elements.
* inline-block - horizontal line of elements, but they can have a width and height.


<source lang="html4strict">
https://developer.mozilla.org/en-US/docs/Web/CSS/display
<!DOCTYPE html>
<html>
<head>
<link href="style.css" rel="stylesheet" />
</head>
<body>
....
</source>

Revision as of 16:02, 12 September 2016

HTML div and span

<div> tag =

The div tag is essentially a square container for other content.

<div style="background:black; color:red; width:400px; height: 400px">                      
    <h1>Beautiful page</h1>                                                     
    <p>writing stuff                                                            
      <i>inside</i>                                                             
    </p>                                                                        
</div>


Abstract Browsing is a Chrome extension by Rafaël Rozendaal that transforms web pages into colored divs.


span tag

<div style="background:black; color:red; width:400px; height: 400px">                      
    <h1>Beautiful page</h1>                                                     
    <p>writing stuff                                                            
      <i>inside</i>                                                             
    </p>                                                                        
</div>


UTF-8 Encoding

Use more than ASCII characters by telling to the browser your page uses UTF-8 encoding scheme.

UTF-8 can represent any character in the Unicode table, including emoji, Chinese, Arabic, Greek, etc characters.

<!DOCTYPE html>
<html>
 <head>
          <meta charset="UTF-8" />
	  <title>😹<</title>
	    </head>
	    </html>
	    <body>
	    <h1>😹<s page</h1>
            </body>
	    </html>

Styling your page with CSS

CSS - Cascading Style Sheets

HTML is not meant to style (inline syling eg:

is old fashion and discouraged). CSS is the preferred to way to style.
  • HTML tell the browser what content it should display
  • CSS tells the browser how to display that content.

CSS inside an HTML page

  • CSS code goes inside the style tags <style> ... </style>
  • <style> ... </style> tags are placed inside the head of the HTML page.
<!DOCTYPE html>
<html>
 <head>
    <style>

     body{
            background: #FF19DC;
	    color: black;
	    font-family: mono;
			        }

   </style>
   </head>
   </html>
   <body></body>
   </html>

anatomy of a css rule

Each CSS style sheet (all the styles of a page) is made of several rules.

Each rule follows the syntax:

Basic-Anatomy-of-a-CSS-Rule1.png

Source: http://dabrook.org/resources/posters/


Example of a CSS rule

  • element: what element(s) is being styled e.g. div
  • property: what property of that element is being styled e.g. color
  • value: how the property is styled e.g. white
div {
      background: blue;
      color: white;
      width: 500px;
      height: 250px;
      font-size:30pt;
	         }

Here we are styling all the div elements in the html page.


CSS Properties

CSS Property reference https://developer.mozilla.org/en-US/docs/Web/CSS/Reference

Some properties.

  • color, background-color, width, height
  • border, box-shadow, list-style
  • margin, padding
  • transform, gradient, border-radius

Use some of these properties and others that you find out in your page.


id and class attributes

Two of the most used attributes in HTML is id and class.

They are important to distinguish and group different elements. And become particularly important in CSS styling.

  • id (#) is used to 'distinguish tags
  • class (.) is used to group tags


id

  • id (#) is used to 'distinguish tags
  • the same id cannot be repeated in the same file. Use only once.
  • The symbol for id is: #
p {color: black;
   font-weight: bold;
      }

p#special{ color: red;
           font-weight: normal;
           transform: matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
		      }
<p id="special">I am specific paragraph with id="special" </p>
<p>Just another paragraph under the tag p .</p>
<p>Another one of the same tag p, without id.</p>

Only the paragraph with id="special" will be effected by the rule above p#special: red, normal weight, transform. The remaining paragraphs are only affect by the rule p {...}

class

  • class (.) is used to group different tags - They become styled by same CSS rule
  • class can be used INFINITE TIMES in a file
  • The symbol for class is: .


p {color: black;
   }

.text{ color: black;
           font-weight: italic ;
	              background: #003366;
		                 color: white;
				 }
				 <div class="text">This is a div tag</div>
				 <span class="text">This is a span tag</span>
				 <p class="text">and this is a p tag</p>
				 <p>Notice how all the above tags with class="text" are styled the same way.</p>
				 <p>These 2 last tags, on the other hand have NOT class="text", and therefore remain are not affected by the CSS rule</p>
				 <p>Also notice how 3 different tags can look the same if they share the same class </p>


inspector

a separate CSS file

The CSS for a HTML page (or several pages) can stored outside that page, in css file.

To do that we need link the HTML file to the CSS file, using the tag link inside the html head.

<link href="style.css" rel="stylesheet" />
<!DOCTYPE html>
<html>
 <head>
  <link href="style.css" rel="stylesheet" />
  </head>
  <body>
  ....


homework

Apply CSS to the content of your weblog

  • Make each entry (past or future) in your weblog will be wrapped inside a div
  • Give each entry div an unique id; and a common class. E.g

....*

  • Style each entry differently
  • ADD content


Online Resources on CSS


Artistic use of CSS

Nan Wang Eyes:

Book Scapes: http://www.julienlevesque.net/books-scapes/index2.html (advanced, maybe to when introduce CSS position )




CSS position, display, float

@andre: study and explain CSS position in next class
https://kilianvalkhof.com/2008/css-xhtml/understanding-css-positioning-part-1/
http://learn.shayhowe.com/html-css/positioning-content/

Position

  • absolute
  • relative

Display

@andre: SEE display property explain in http://dustwell.com/div-span-inline-block.html http://stackoverflow.com/questions/9189810/css-display-inline-vs-inline-block
  • none / hidden - turns to none (hides) the display of the element.
  • inline - horizontal line of elements, but width and hide will be define by its content.
  • block - vertical stack of elements.
  • inline-block - horizontal line of elements, but they can have a width and height.

https://developer.mozilla.org/en-US/docs/Web/CSS/display