Thursday, October 9, 2014

Web Design - Basic elements of a web page


Download the files for this intro web design lesson from here 

How  web pages render. 

Web pages (or web document) are built using plain text files with special syntax.

Example:
<!DOCTYPE html>
<html>
<body>
<h1>
My First Heading</h1>
My first paragraph.
</body>
</html>

They are stored on web servers whether they be on a physical server, cloud server, or some other hosting system. Web servers wait for requests for documents and assets from web browsers. Assets usually consist of images, javascript files, and CSS files.

When a user points their web browser to a particular web address it creates a request to download the web page document to your browser for processing. If the syntax is correct within the web document then the page is rendered in your browser.

How to create a simple web document

1) Download a copy of notepad++ or sublime text 2
2) Create a new document
3) copy and paste this html text into your document

<!DOCTYPE html>
<html>
<body>
<h1>
My First Heading</h1>
My first paragraph.
</body>
</html>

4) Save it as test.html and double click it to open it in your web browser

Parts of a web document

<!DOCTYPE html>
<html>
<head><title>Page 1</title>
<style >
#header {
    background-color:red;
    color:yellow;
    text-align:center;
    padding:10px;
}
#nav {
    line-height:30px;
    background-color:#999999;
    height:350px;
    width:150px;
    float:left;
    padding:15px;
}
#section {
    width:400px;
    float:left;
    padding:15px;
}
#footer {
    background-color:red;
    color:white;
    clear:both;
    text-align:center;
    padding:15px;
}
</style>
</head>
<body>

  <div id="header">
  <h1>Some header</h1>
  </div>

  <div id="nav">
  Page1<br/>
  Page2<br/>
  Page3<br/>
  </div>

  <div id="section">
  <h1>Page 1</h1>
  <p>
  I'm a paragraph
  </p>
  <p>
  I'm a paragraph too</p>
  </div>

  <div id="footer">
  I'm a footer
  </div>
</body>
</html>

Let's go over the above. Our web page is broken down into main elements  which are separated by tags. We use the div tags to divide a html document so we get the layout we desire. Typically a web document is divided so it has a header, menu or navigation , body and footer. This is totally arbitrary but it is a good design because it allows users to navigate your site easily with a menu and there is enough real estate to brand your website and provide content. The style tag allows us to take advantage of CSS. There are few rules here and they directly pertain to the tags we defined in the body tag. As you probably noticed the div tags have id attributes to distinguish them. These allow us to easily apply CSS to them as above.

Exercise:

Try creating the other 2 pages and link them together. So page 1 through 3 are each can link to each other.



Intro to Bootstrap


Try the following example for bootstrap. Get a copy of it from here : http://getbootstrap.com/getting-started/

<!DOCTYPE html>
<html>
<head><title>Page 1</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">

</head>
<body>

    <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Project name</a>
        </div>

      </div>
    </div>

    <!-- Main jumbotron for a primary marketing message or call to action -->
    <div class="jumbotron">
      <div class="container">
        <h1>Hello, world!</h1>
        <p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
        <p><a class="btn btn-primary btn-lg" role="button">Learn more ></a></p>
      </div>
    </div>

    <div class="container">
      <!-- Example row of columns -->
      <div class="row">
        <div class="col-md-4">
          <h2>Heading</h2>
          <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
          <p><a class="btn btn-default" href="#" role="button">View details ></a></p>
        </div>
        <div class="col-md-4">
          <h2>Heading</h2>
          <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
          <p><a class="btn btn-default" href="#" role="button">View details ></a></p>
       </div>
        <div class="col-md-4">
          <h2>Heading</h2>
          <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
          <p><a class="btn btn-default" href="#" role="button">View details ></a></p>
        </div>
      </div>

      <hr>

      <footer>
        <p>© Company 2014</p>
      </footer>
    </div> <!-- /container -->


    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>


</body>
</html>

Exercise: try sprucing up the layout we created before using bootstrap. 

No comments:

Post a Comment