Tag,You re It! HTML Markup Made Easier with Cascading Style Sheets By Larry Kahm

Similar documents
c122jan2714.notebook January 27, 2014

2. Write style rules for how you d like certain elements to look.

Understanding the Web Design Environment. Principles of Web Design, Third Edition

Hypertext Markup Language, or HTML, is a markup

Styles, Style Sheets, the Box Model and Liquid Layout

ADDING CSS TO YOUR HTML DOCUMENT. A FEW CSS VALUES (colour, size and the box model)

Chapter 7 Typography, Style Sheets, and Color. Mrs. Johnson

Introduction to WEB PROGRAMMING

PART COPYRIGHTED MATERIAL. Getting Started LEARN TO: Understand HTML, its uses, and related tools. Create HTML documents. Link HTML documents

Tutorial 1 Getting Started with HTML5. HTML, CSS, and Dynamic HTML 5 TH EDITION

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

Developing a Basic Web Page

This document provides a concise, introductory lesson in HTML formatting.

Using Dreamweaver CC. Logo. 4 Creating a Template. Page Heading. Page content in this area. About Us Gallery Ordering Contact Us Links

The Nature of the Web

CSS - Cascading Style Sheets

<body bgcolor=" " fgcolor=" " link=" " vlink=" " alink=" "> These body attributes have now been deprecated, and should not be used in XHTML.

Reading 2.2 Cascading Style Sheets

HTML and CSS a further introduction

The internet is a worldwide collection of networks that link millions of computers. These links allow the computers to share and send data.

COMSC-030 Web Site Development- Part 1. Part-Time Instructor: Joenil Mistal

Introduction to Web Programming and Design

CISC1600-SummerII2012-Raphael-lec3 1

Cascading Style Sheets. Overview and Basic use of CSS

CSC 121 Computers and Scientific Thinking

Unit 5 Web Publishing Systems Page 1 of 13 Part 4 HTML Part 4

Introduction to Multimedia. MMP100 Spring 2016 thiserichagan.com/mmp100

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2)

INTRODUCTION TO HTML5! CSS Styles!

Figure 1 Properties panel, HTML mode

Html basics Course Outline

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

HTMLnotesS15.notebook. January 25, 2015

Getting Started with Eric Meyer's CSS Sculptor 1.0

recall: a Web page is a text document that contains additional formatting information in the HyperText Markup Language (HTML)

CSS worksheet. JMC 105 Drake University

Dreamweaver CS6. Level 1. Topics Workspaces Basic HTML Basic CSS

INTRODUCTION TO CSS. Mohammad Jawad Kadhim

COMS 359: Interactive Media

INFORMATICA GENERALE 2014/2015 LINGUAGGI DI MARKUP CSS

Creating Web Pages with SeaMonkey Composer

Before you begin, make sure you have the images for these exercises saved in the location where you intend to create the Nuklear Family Website.

Introduction: History of HTML & XHTML

What is CSS? NAME: INSERT OPENING GRAPHIC HERE:

Objectives. Introduction to HTML. Objectives. Objectives

Formatting Text. 05_Format rd July 2000

Web Design and Implementation

ITNP43: HTML Lecture 4

Using Dreamweaver CS6

CSC9B1: Essential Skills WWW 1

Introduction to Cascading Style Sheet (CSS)

Web Page Creation Part I. CS27101 Introduction to Web Interface Design Prof. Angela Guercio

Dreamweaver Domain 5: Organizing Content by Using Dreamweaver CS5

It is possible to create webpages without knowing anything about the HTML source behind the page.

A Guided Tour of Doc-To-Help

Web Development & Design Foundations with HTML5

Introduction to web development and HTML MGMT 230 LAB

UNIT -II. Language-History and Versions Introduction JavaScript in Perspective-

BIM222 Internet Programming

Using Dreamweaver CS6

Which is why we ll now be learning how to write in CSS (or cascading sheet style)

WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5

Web Design and Development ACS-1809

Beginning HTML. A tag is a command written between angle brackets (the less than and greater than symbols). Ex. <html>

(Refer Slide Time: 01:41) (Refer Slide Time: 01:42)

3.1 Introduction. 3.2 Levels of Style Sheets. - HTML is primarily concerned with content, rather than style. - There are three levels of style sheets

CSS: The Basics CISC 282 September 20, 2014

A Brief Introduction to HTML

DAY 4. Coding External Style Sheets

A Balanced Introduction to Computer Science, 3/E

Microsoft Expression Web Quickstart Guide

Dreamweaver: Accessible Web Sites

HTML. Mohammed Alhessi M.Sc. Geomatics Engineering. Internet GIS Technologies كلية اآلداب - قسم الجغرافيا نظم المعلومات الجغرافية

Activity 4.1: Creating a new Cascading Style Sheet

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web

CSS BASICS. selector { property: value; }

ICT IGCSE Practical Revision Presentation Web Authoring

Assignments (4) Assessment as per Schedule (2)

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar with Dynamic Background Image

HTML TIPS FOR DESIGNING.

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

- HTML is primarily concerned with content, rather than style. - However, tags have presentation properties, for which browsers have default values

RICH ENTERPRISES. Small Business Series. Getting Started with HTML

A network is a group of two or more computers that are connected to share resources and information.

Announcements. 1. Class webpage: Have you been reading the announcements? Lecture slides and coding examples will be posted

Using CSS in Web Site Design

ICT IGCSE Practical Revision Presentation Web Authoring

Chapter 5 Making Life Easier with Templates and Styles

CREATING A WEBSITE USING CSS. Mrs. Procopio CTEC6 MYP1

By completing this practical, the students will learn how to accomplish the following tasks:

TUTORIAL MADCAP FLARE Tripane and PDF

Part II: Creating Visio Drawings

How to lay out a web page with CSS

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

Downloads: Google Chrome Browser (Free) - Adobe Brackets (Free) -

Page Layout Using Tables

INTRODUCTION TO HTML5! HTML5 Page Structure!

.hedgehog { background-image: url(backyard.jpg); color: #ffff99; height: 6in; width: 12in; } .tube {

Animation and style sheets

Background of HTML and the Internet

Transcription:

Tag,You re It! HTML Markup Made Easier with Cascading Style Sheets By Larry Kahm Everyone needs to have their documents look a certain way while keeping their pages easy to modify and the internal processing code down to a minimum.this article explains how and concludes with a demonstration of how CSS can be used to format the HTML in a manner that separates content from presentation. INTRODUCTION Everyone needs to have their documents look a certain way, either for in-house standards or their own preference. How can you accomplish that while keeping your pages easy to modify and the internal processing code down to a minimum? This article presents you with an introduction to Cascading Style Sheets (CSS) in a manner that makes them easy to understand. I begin with a brief review of IBM s Generalized Markup Language (GML) and how it is used. I continue with a brief overview of a Web page based on Hypertext Markup Language (HTML) and describe one means by which a GML document can be converted to an HTML document. Finally, I bring all of this together by demonstrating how CSS can be used to format the HTML in a manner that separates content from presentation. This article concludes with several references so that you can conduct additional research on your own. GML 101, THE BASICS I first learned about IBM s Generalized Markup Language (GML) in the mid-1980s. At that time, I was primarily involved in technical writing. I ll admit the transition from a word processing workstation (Wang) to mainframe-based text processing using ISPF as the text editor was a strange one. However, once I sat down and learned about how the tags were used, and how they were constructed, it became very easy. Let s start at the beginning. Every document has an organization or structure that is made up of distinct components. Each component that comprises the structure has a relationship with other components. GML uses tags to define each of these components and how they relate to others. IBM designed it this way so that as an author, you did not have to concern yourself with the mechanics of how this worked; instead, you could focus on the content of the document. The simplest component of any document is a paragraph. Using GML, a paragraph is designated by the following tag: :p. FIGURE 1: SAMPLE DOCUMENT CODED WITH GML TAGS :gdoc. :body. :h1.this is a level 1 heading :p. :h2.this is a level 2 heading :p.notice no space is skipped between the heading and this paragraph. :p. :ul. :li.the typeface is Lucinda Console (the default in Notepad running under Windows XP). :li.there are no distinguish formatting factors other than this list. :eul. :h3.this is a level 3 heading :p.default GML tags from the IBM-supplied Starter Set were used in this example. :egdoc. All GML tags start with a colon and end with a period. Most tags are used in pairs and contain a starting keyword and a matching ending keyword. For example: :ul. starts an unordered (bullet) list :eul. ends an unordered list Some tags even have attributes, which lets you provide additional information or customize some of the processing. When a document containing GML tags is processed, several rules are evaluated and implemented. For instance, the paragraph tag implicitly closes off any other open tag, skips a line, and (for the most part) starts the text flush against the left-hand margin. These rules are processed through a software program called SCRIPT. The rules are

contained in a macro library and are read and expanded during processing. This is the core of IBM s Document Composition Facility (DCF), which is now known as BookMaster. What was so difficult to adjust to for many writers was that the file you saw on your 3270 display screen was nothing like what actually appeared on the page. SCRIPT generated a data stream that was interpreted by an Advanced Function Printing (AFP) device, such as a 3820 printer. So, what you saw during edit was not at all what you got from the printer. For that matter, I am certain IBM never intended for so many pages to be wasted as people tried to get a document to format exactly the way they wanted. As I mentioned, GML used a highly stylized document structure. A sample is shown in FIGURE 1. As you can see, there is a tag to designate the start of a document. There are optional tags that can be used for the components that make up the front matter of a book (for example, table of contents, forward, list of figures, and so on). The body tag ends the front matter and begins the main section of the document. As you look closer, you can see further evidence of the hierarchy in a document. There are various heading levels, paragraphs and even a list. I did not include an example of a table because the code would become too long and complex. A document can have optional back matter, which consists of appendixes and an index. The document actually ends when the enddocument tag is processed. Unfortunately, I cannot show you what the contents of FIGURE 1 looks like after it is processed by a printer; I don t have one available. So, to review: GML defines a document s structure. It separates the content from the actual formatting (output). It uses tags to identify the components (elements) of the document. It allows authors to concentrate on the content of the document instead of on how it will be processed. GML, A LITTLE DETAIL Now, despite having said that authors don t need to understand how a document is processed, we as software specialists do. When you print a GML document, one of the instructions you give the SCRIPT program is the name of the profile that you want it to use to process your document. IBM provided a member in a macro library that performed FIGURE 2: CONTENTS OF DSMPARA MACRO.* DSMPARA: Tag = P No Attr. Spaces between paragraphs and indents *.* first line. *.***********************************************************************.sk &@sk@p.il +&@in@p FIGURE 3: SAMPLE DOCUMENT WHERE GML TAGS HAVE BEEN CONVERTED TO HTML This is a level 1 heading This is a level 2 heading Notice no space is skipped between the heading and this paragraph in the source code. However, notice how much space is used by the headings when they are displayed in a browser. The typeface is Lucinda Console (the default in Notepad running under Windows XP). There are no distinguishing formatting factors other than this list This is a level 3 heading Default HTML tags were used for this example. processing for their starter set of tags. The member name is DSMPROF4. It contains the formatting instructions for each of the tags. Let s take the paragraph tag, because it is the simplest. In DSMPROF4, the following instruction appears:.aa p dsmpara (noatt) This uses a SCRIPT control word,.aa, to associate the GML tag to the name of the macro that contains the tag s rules. The (noatt) keyword indicates that there are no attributes allowed for this tag. The macro expansion takes place after all of the lines of the profile have been processed. To continue our research, let s look at the contents of the macro, DSMPARA, as shown in FIGURE 2. The first three lines are comments to let you know the exact nature of the processing that will take place. The fourth line contains a control word to instruct the processor to skip the designated number of lines before proceeding. The fifth line contains a control word to instruct the processor to indent the line the specified amount. Again, as an author, you would never need to know this kind of detail. You would simply type your document and place the necessary tags wherever they were appropriate. That made it easier to get the work done. At some sites, technical editors would take it upon themselves to either modify the IBM starter set or create an entirely different processing profile. Because the starter set was just that, it was not a solution for everyone s inhouse publications. In addition to modifying the profile, you could also create your own macros, or modify the IBM-provided macros, using the native SCRIPT control words to produce exactly what you wanted to print. In the early 1990s, I was contracted by the Gartner Group to modify one of their SCRIPT profiles to produce their research documents. HTML 101, THE BASICS But how does this relate to CSS? I m getting there. But before I do, I need to explain a little bit about HTML and show how Web pages (Web-based documents) are formatted. The World Wide Web Consortium (W3C) has developed a specification for the rules by which a Web page can be created. By now, most of us are quite familiar with the various looks and flavors that a Web page can have on different browsers and Web sites. In its purest sense, HTML is nothing more than a markup language. In the same manner that GML describes how to create a printed document, HTML describes how to build an online document. And, in the same way that a printed document has a structure, so does a Web page. FIGURE 3 contains a slightly edited form of the GML document that I showed you in FIGURE 1. I used a software tool called B2H, which was developed by Gary L. Richtmeyer of AT&T Labs in Tampa, Florida. (Please refer to the Resources section at the end of this article for additional information.) B2H converts GML documents to HTML documents. I did change some of the text in the example so that it was more appropriate for the discussion.

As you can see, the structure of the document has been retained following the conversion to HTML. What is different is how HTML defines tags. In HTML, tags are surrounded by brackets, and the ending tag is designated with a slash. For example: FIGURE 4: SAMPLE DOCUMENT WITH HTML RENDERED BY A BROWSER <ul> starts an unordered (bullet) list </ul> ends an unordered list The B2H utility understands these conventions and transforms one document markup format to another. When the contents of FIGURE 3 are saved to a file that has an htm or html extension, you can open it with a Web browser and view the formatted contents. The Web browser controls the formatting and layout of an HTML document similar to the way a printer does for a GML document. FIGURE 4 shows the results in Internet Explorer 6.0. That s quite a difference from what the unformatted code looked like. But it sure is ugly. The font is now Times New Roman; the font in the source is not used for the display. The headings are large, which we can understand, but are followed by a tremendous amount of white space. In the end, there is no pizzazz to this page irrespective of the information that is conveyed. GOOD-LOOKING HTML PAGES Finally, he s going to talk about CSS, right? Well, almost. Let s address more about content and format. While you can engineer HTML code so that when it is displayed, it appears prettier, you end up taking away from the content. Take a look at FIGURE 5. Here, I ve used Microsoft FrontPage to add some additional markup to make the page look nicer. As you can see, there are font tags, spacing, and a few other tricks. FIGURE 6 shows the result as it appears in a browser. Wow, what a difference! But you ll also notice that most of the actual text is now effectively hidden by all of the coding to support these new features. Some of this is due to the software tool I used to make the change (which is why using a WYSIWYG HTML editor is not always the best solution). If this were a complex document, or one that spanned several dozen pages, I would have a heck of a time trying to update it in the future. Especially if management indicated that the color big blue was no FIGURE 5: SAMPLE DOCUMENT WITH HTML MODIFIED BY FRONTPAGE This is a heading - level 1 This is a heading - level 2 Notice no space is skipped between the heading and this paragraph in the source code. However, notice how much space is used by the headings when they are displayed in a browser. The second paragraph (and following) is indented. The typeface has been changed to Arial. There are no distinguishing formatting factors other than this list (although the color of the text is now big blue.) This is a heading - level 3 No style sheet was used for this code. This HTML code was modified using an HTML editor. FIGURE 6: SAMPLE DOCUMENT WITH MODIFIED HTML RENDERED BY A BROWSER

FIGURE 7: SAMPLE DOCUMENT WITH STYLE SHEET This is a heading - level 1 This is a heading - level 2 Notice how much less space is now used in the browser by the headings. The second paragraph is indented The typeface has been changed to Verdana Notice how even the bullets in the list have been changed to red This is a heading - level 3 A sample style sheet was used for this code. This HTML was modified using Notepad. FIGURE 8: SAMPLE DOCUMENT WITH STYLE SHEET RENDERED BY A BROWSER Use the following construct to indicate to the browser that you want to use a style sheet: <style> <! Your code will go in here > </style> The style tag starts the definition and has an end tag. Inside the tags are comments to allow older browsers (which don t support style sheets) to ignore the contents and not render them as text. What you code depends on what you want to accomplish. CSS IN DEPTH Here are the changes I am going to make to this document: 1. Change the font the document is displayed in from Arial to Verdana 2. Indent the first line of each second paragraph 3. Change the color of the list items from big blue to red mond longer a corporate standard but that the color red mond was. OK, so how do you remove extraneous coding from the tags? Well, that is what CSS is all about. It lets you define styles for all of your specific formatting. You simply put references to the styles in your document. Most Web browsers (especially the latest versions) understand how to use the formatting and present the appropriate output. The net result: You have effectively separated content and format. This was what the markup languages were intended to do in the first place. CSS INTRODUCTION 101 Finally, he s going to tell us about CSS! Yes, I am. Style sheets are nothing more than a set of specific processing instructions for the browser to use to render your document. The advantage to using them is that you can define a characteristic just once, and it can be used everywhere in your document. What can you manipulate? The following, for starters: Font properties for example, type face, size and weight Text properties for example, alignment or word spacing Color and background properties for example, standard colors and images Recall how the GML paragraph tag was associated with a macro and that the macro contained instructions to the SCRIPT processor for how many spaces to indent and how many lines to skip? Well, when you define a style for HTML processing, you build a similar construct in a style sheet. Yes, a style sheet can be considered nothing more than a macro (or even a library of macros). Let s take each one of these tasks separately. When FrontPage updated the HTML code, it performed a very simple chore. It added a <font> tag to each line of code in the document. While that is technically accurate, over the course of several hundreds of lines, and possibly several dozen pages, this is excessive. Many Web pages have this kind of bloat, which sometimes takes them longer to render in your Web browser. Instead, I am going to remove all of the font tags (including the attributes) and the corresponding end font tags. I am then going to update the style sheet to include the following statement: BODY{ font-family: Verdana } Does this construct look familiar? It should; this is just like the SCRIPT control word processing for the paragraph tag in GML. This style sheet code instructs the Web browser that when it encounters the <body> tag in a document, it should apply the font Verdana to every element until the </body> tag is encountered. That s it just one line of code, not hundreds. (Yes, inheritance is one of the powerful aspects of style sheets.)

To indent the first line of a paragraph, I am going to create a new class for the HTML paragraph tag. This will allow me to indent only the paragraphs that I want. The rest of the time, the paragraph tag will be interpreted normally. To do this, I am going to update my style sheet to include the following statement: P.nextpara{ text-indent: 16px } This instructs the Web browser to indent any paragraph that has the class nextpara by 16 pixels. Finally, I am going to change the color of the list items from blue to red. By now, you can probably guess what that code looks like. To make it easier, take a look at FIGURE 7. This contains the sample document with the complete style sheet. Notice that it is contained in the heading of the page so that it can affect all of the code in the document. FIGURE 8 depicts what this document looks like when rendered by a Web browser. As you can see, the code is much cleaner and the content is more readily visible for anyone to maintain. But what happens if your site contains several dozen, or even hundreds, of Web pages? If you code this style sheet in all of them, you still run into a problem if (or when) you need to make a global change. Fortunately, there is a very easy solution. You simply take your style sheet code and place it in a separate file. Then, within your document, you refer to it. Here s an example: <link rel= stylesheet href= mystyles.css type= text/css > Using a link, you can make one change and have it propagate to your entire Web site. You can even create a set of style sheets for each type of page or subset of pages on your site. More advanced processing is possible with style sheets. You can align images and whole sections of text without very much code. You can even duplicate most of the formatting you see in the pages of Technical Support magazine. However, that is well beyond the scope of this article. CONCLUSION From the start, markup languages were designed to keep content and format separate. It was only with the introduction of a ubiquitous Web browser that Web page developers wanted to format their content in a manner that was unique and different. WYSIWYG Resources GML The basic information needed to get started with GML can be found in the Starter Set; more advanced coding techniques can be found in the SCRIPT Language Reference. Document Composition Facility: Generalized Markup Language Starter Set User s Guide, SH20-9186 Document Composition Facility: SCRIPT/VS Language Reference, SH35-0070 HTML The W3C is the primary location for all of the information you need about the latest proposals to HTML and related Web-based coding. A few other useful sites are also listed. World Wide Web Consortium (W3C): http://www.w3.org http://www.pageresource.com/ http://www.w3schools.com/ B2H This is an extremely handy utility that lets you take existing documentation and transform it so that it can be viewed on an intranet or the Internet. Description: http://www.vm.ibm.com/download/packages/descript.cgi?b2h Download: http://www.vm.ibm.com/download/packages/ CSS More detailed information about style sheets than you can possibly imagine can be found here. Or, you can read any of the books by Eric Meyer, a true genius when it comes to explaining how CSS can work. Cascading Styles Sheets at the W3C: http://www.w3.org/style/css/ Eric Meyer, Eric Meyer on CSS, New Riders, 2003 HTML editor helped authors create highly formatted documents. However, the attempts to use HTML to format the page lead to a huge increase in the size of HTML pages. The net result was a corresponding decrease in the ability to obtain access to just the content. Now, with browsers showing up in various sizes and devices, it is even more important to keep content separate from format. By using CSS, you can achieve that goal. I have shown you a rudimentary approach for converting an existing document into a Webbased page. I then took you through the steps to reformat that document using style sheets. The rest is up to you, your existing content, your site s standards, and your imagination. NaSPA member Larry Kahm is president of Heliotropic Systems, Inc., an IBM Business Partner located in Fort Lee, N.J. He has 15 years of experience evaluating and deploying mainframe productivity tools and advocating their use. His areas of expertise include application change management (methodology and software solutions), application development technical support, ISPF dialog development, and technical writing. He can be contacted via email at lkahm@heliotropicsystems.com.