Thursday, October 25, 2012

A Short Guide to CSS

Oracle Applications allows creation of Custom Look and Feel. All these custom look and feel creates a new CSS. We also define CSS property for many UI Widgets like OraDataText etc. All the existing skins defined in the profile option Oracle Applications Look and Feel also maintain their own style and thus their own css. You can find all the CSS at $OA_HTML/cabo/styles/cache in your file server. We'll learn basics of CSS here.

CSS

  • CSS stands for Cascading Style Sheets.
  • External Style Sheets are stored in CSS files.
  • Allows to separate HTML content from it’s style. Use your HTML file to arrange the content, and CSS for all of the presentation.
  • External CSS are shared and thus allows us to change Look and Feel of entire website by modifying one CSS file. 
  • CSS improves performance because style sheet only needs to be downloaded to client machine and then it's used from cache.
  • A nested element will inherit the properties assigned to the containing element.
  • In case if same style is mentioned multiple times in same CSS/HTML file, the effect is cascaded. Following are the rules:
    • If same style is defined multiple times in a file, then the one defined at the end will take preference in case if same property is defined.
    • Inline Style - Highest Priority
    • Internal Style Sheet - High Priority
    • External Style Sheet - Normal Priority
    • Browser Default - Low Priority
  • Divisions(<div>) are a block level (X)HTML element used to define sections of an (X)HTML file.
  • Spans(<span>) are very similar to divisions except they are an inline element versus a block level element.
  • width:40% will work with <div> and not with <span>, as div is block level while span is inline.
  Sample CSS Syntax

   selector {property:value;}
    p {color:red;text-align:center;}
    /* Below is syntax in more readable form */

    p
    {
        color:red;
        text-align:center;

    }
  • P is called Selector.
  • "color:red;" and "text-align:center;" are called declaration.
  • Every declaration ends with semi colon, and contains a property and value.
  • Every declaration group is surrounded by curly brackets.
  • /* .. */ is used for comments.
  • We can combine multiple selectors together while defining CSS
    h1, h2, h3, h4, h5, h6 
    {
        color: #009900;
        font-family: Georgia, sans-serif;
    }
      Inline Style
    • Uses HTML attribute style for this. 
      • <body style="background-color: #FF0000;">
        Internal Stylesheet
      • Placing CSS code directly into the <HEAD> section.
           <head>
               <title><title>
               <style type=”text/css”>

                   // CSS Content Goes Here
                   body
                   {
                       background-color:#d0e4fe;
                   }
               </style>
           </head>

      • <style> tag is used to define style information for a HTML document.
      • <style> tag can appear multiple times in a HTML document.
        External Stylesheet
      • Created as external file and linked to the HTML document.
      • We can link to the file externally by using either <link> or <style> with @import in the <head> section. 
           <link rel=”stylesheet” type=”text/css” href=“Path To stylesheet.css” />
           
           <style type="text/css">
               @import url("import3.css");
               p { color : #f00; }
           </style>

      • <link> is intended to link together your Web page with your style sheet.
      • <link> tag defines the relationship between a document and an external resource.
      • <link> element is an empty element, it contains attributes only.
      • <link> element can appear any number of times in <HEAD> section.
      • @import allows you to import one style sheet into another.
      • @import is a way of creating a style sheet within your document, and then importing additional rules into the document.
      • @import rule must always be the first in the document. Even comments shouldn't come before this.
      • <link> element gives better performance and more readable code compared to @import.

      Selector Type

        HTML Selector
      •  To redefine the general look for an entire HTML tag.
          p
          {

              font-family:verdana;
              text-align:left;
              color:blue;
          }


        Id Selector
      •  The id selector is used to specify a style for a single, unique element.
          #book
          {
              text-align:left;
              color:blue;
          }

          <div id="book">
              This is my first book. I wis
      h to write a technical book once...
          </div>

        Class Selector
      • Used to specify a style for a group of elements.
      • Can specify specific HTML elements which should be affected by a class.
          .red{color:red;} 
          p.red{color:red;}

        Context Dependent Selector or Nested Selector or  Decendant  Selector
      • Used to specify a style for a selector when its used in conjunction with another one.
           p b{color:red;font-weight:bold;}

           innerClassSelector {color:pink;}
           outerClassSelector {color:red;}
           .outerClassSelector .innerClassSelector{color:blue;}
      • When innerClassSelector is used inside outerClassSelector then this style will be applicable, else the default of innerClassSelector will be applicable.  innerClassSelector  needn't be the immediate child, but it should be in the same hierarchy.
      • Context dependent is specified by separating two classes with a space.
         Immediate Child Selector or child combinator selector
      • Similar to Context Dependent Selector but it looks for immediate child only.
      • It impacts only the first child.
          p > b{color:red;font-weight:bold;} 

          Adjacent Sibling Selector
        • It will style only the element that is immediately preceded by the former element.
             #MAN + p {color:green;}


          General Sibling Selector
        • It will style only the element that is preceded by the former element, may not be immediatly.
             #MAN ~ p {color:green;}

          Attribute Selector
        • Style HTML elements that have specific attributes.
            [title]{color:green;}

          Attribute and Value Selector
        • Below Styles all elements with title="Custom Product Branding":
            [title="Custom Product Branding"] {color:green;}
        • Below styles all elements with a title attribute that contains word "Hello":
            [title~=Hello] {color:green;}
          • It'll work for "Hello World", "World Hello" but will not work with "Hello-world".
          • [title~="Hello"] is same as [title~=Hello]
          • [title~="Hello World"] or  [title~="Hello "] will not select anything for Styling.
        • Below works if the attribute has hyphen ( - ) separated values:
            [title|=Hello] {color:green;}
          • It'll work for "Hello", "Hello-World" but will not work with "Hello World",  "World Hello" or "Hello!".
          • Mostly used for specifying languages.
        • Below works if the attribute contains word "Hello" anywhere in value:
            [title*=Hello] {color:green;}
        • Below works if the attribute begins with " http" anywhere in value:
            a[href^="http"] {color:green;}
        • Below works if the attribute ends with " .jpg" anywhere in value:
            a[href$=".jpg"] {color:green;}


        The CSS Box Model

        • Every element in web design is a rectangular box.
        • Calculate Dimensions as follows:

          Some Key Style Properties:

          text-decoration
          Set or remove decorations from text, mostly used to remove underlines from link
          h1 {text-decoration:overline;}
          h2 {text-decoration:line-through;}
          h3 {text-decoration:underline;}
          h4 {text-decoration:blink;}

          text-transform 
          To specify uppercase and lowercase letters in a text.
          p.uppercase {text-transform:uppercase;} <!-- All Upper case -->
          p.lowercase {text-transform:lowercase;} <!-- All Lower case -->
          p.capitalize {text-transform:capitalize;} <!-- Camel case -->

          text-indentation
          To specify the indentation of the first line of a text, like we have in paragraphs in book.

          list-style-image:url('listImage.gif');
          To specify image to be used for lists (instead of default square or circle etc)


          list-style-type:none;
          Will display list without any circle or square.
          display:inline; when used within the list, will display horizontal list.

          Display and Visibility
          .hide{visibility:hidden;}
          .hide{display:none;}
          visibility:hidden hides an element, but it will still take up the same space as before.
          display:none doesn't take up any space.

          :first-child Pseudo-class
          Styles a specified element that is the first child of another element.
          p:first-child{color:blue;} 

          Style the first p element
          .outerClass > .innerClass:first-child
          Styles first .innerClass element in all .outerClass elements.
          .outerClass:first-child .innerClass
          Styles all .innerClass elements in first .outerClass element.



          :first-letter and :first-line Pseudo-element
          The :first-letter selector is used to add a style to the first letter of the specified selector.
          :first-line Styles the first line of text in a block level element.
          p:first-letter, div:first-letter {font-size:medium; color:#ff0000;}
          p:first-line, div:first-line {font-size:medium; color: #00ff00;}
          p.intro:first-line, div:first-line {font-size:medium; color: #00ff00;}

          opacity
          Create a transparent images and text with CSS.
          img
          {
          opacity:0.5;
          filter:alpha(opacity=50); /* For IE8 and earlier */
          }



          @media Rule
          Media Types allow you to specify how documents will be presented in different media.
          @media screen
            {
            p {color:red;}
            }
          @media print
            {
            p {color:green;}
            }

          Tips:
          • Adding a border on hover makes images look coming out on mouse hover in Page.

          Few New Features in CSS3:

          • Border-radius
          • @font-face
          • Box-shadow 
          • 2D Transforms
          • Multi-Column Layout
          • Multiple Backgrounds
          • Opacity

          Tuesday, October 16, 2012

          A short guide on HTML

          We all are working on Web Developments, and underneath all webpages is good old HTML. It helps to understand HTML a bit. I realized it more while working on new OAF CLAF. The challenge was to match the new Oracle Apps skin with the corporate website built on .net. Along with HTML, knowledge of UIX, CSS, and JAVASCRIPT is required for CLAF. Hope to cover it all, starting with HTML.
          • Every web page you create must include the <HTML>, <HEAD>, <TITLE> and <BODY> tags.
          • <TITLE> is used to identify the page on Bookmarks and Favorites list.
          • The web addresses contained in a web page are of two types - Absolute (complete address) and relative (address of the resource from current page).
          • File Extension (.JSP, .jsp) and (.HTM, .htm) could refer to same file on windows server but different on unix server. Its better to be uniform in the use of extension.
          • HTML to download a file:
               <A HREF="Prince_Kapoor2012.docx"> Click here to download my resume</A>

          • While testing your application it'll be a nice idea to test your pages in less color and less resolution mode.
          • There are actually two ways of making text display as bold: <b> and <Strong> and Italics: <I>, <EM>. Purists prefer to use <Strong> and <EM> because they imply that the text should receive special emphasis, rather than dictating exactly how that effect should be achieved. <B> and <I> remain the more popular of the two options.
          •  Every form must begin with a form tag, which can be located anywhere in the body of the HTML document. The <Form> tag normally has two attributes, METHOD and ACTION:
               <form action="mailto:princekapoor82@gmail.com" method="post">
          •  <!--    --> indicates comments.
          • The format of color code is #RRGGBB, where rr, gg and bb are two digit hexadecimal values for the red, green and blue.
          • Please be aware that different computer monitors may display colors in very different hues. A shade of blue on one monitor may look purple in another. Sticking to named colors is preferred choice.
          • Spacer component of OAF and empty space in others is created as a small transparent images used in Img tag with width and height attributes. (/OA_HTML/cabo/images/t.gif)
          • An HTML table is an orderly arrangement of text and/or graphics into vertical columns and rows.
            • OAF Table, AdvanceTable and TableLayout both are rendered as HTML table.
            • Even the MessageTextInput is rendered as an HTML table with prompts as separate column (right aligned) and values as separate (left aligned).
            • Closing </TD> is optional, since one cell of the table must end before the next one begins.
            • Tags used in one cell are not carried over to other cells and tags from outside the table don't apply within the table.
          • A Search Engine is an automated computer program that looks in a database index for pages that contain specific words and phrases. 
          • A Robot (also called a Spider) is an automated computer program that spends all day looking at the web pages all over the internet and building a database of the contents of all the pages it visits. They work for building the database of the Search Engine.
          • The <meta> tag provides metadata about the HTML document. Metadata will not be displayed on the page, but will be machine parsable.
            • Meta elements are typically used to specify page description, keywords, author of the document, last modified, and other metadata.
            • The metadata can be used by browsers (how to display content or reload page), search engines (keywords), or other web services.
            • It is put in <Head> portion of a document.
          <META NAME ="description" CONTENT="Prince Kapoor OAF Blog.">
          <META NAME="keywords" CONTENT="OAF, ADF, Oracle Apps Framework, Oracle Apps Technical, Oracle Application Framework">

          The first tag gives search engine accurate information about your web page and second slightly increases page's ranking on the result based of the keywords.

          NAME -  Specifies a name for the metadata. Values for this attribute are application-name, author, description, generator, keywords.

          Following is usually the first line in the <Head> section:
            • HTML 4.01: <meta http-equiv="content-type" content="text/html; charset=UTF-8">
            • HTML5: <meta charset="UTF-8">
          http-equiv - Provides an HTTP header for the information/value of the content attribute. Values for this attribute are content-type, default-style, refresh.
          content - Gives the value associated with the http-equiv or name attribute.
          charset - Specifies the character encoding for the HTML document. 

          Following will refresh the document every 30 secs
          <meta http-equiv="refresh" content="30">
          • Frames
            • Way of arranging and presenting several web pages at once.
            • Rectangular region within the browser window that displays a page, alongside other pages in other frames.
          • Frameset
            • Frameset document is an HTML page that instructs the Web Browser to split its window into multiple frames and specifies which web page should be displayed in each frame.
          • IFrame
            • The Iframe (Inline Frame - Inline with the data on text/graphics on the page) is set up as a rigid size window frame that scrolls along with the rest of the page and it can exist without having a frameset defined. 
            • Designed to insert interactive applications in Web pages.
            • Frameset is not required for IFrame.
            • One can alter an IFrame’s sections without requiring the user to reload the surrounding page.
            • PPRs in OAF are implemented using IFRAMEs
          • In the HTML source of any OAF page, you'll see <div> and <span> used very frequently with the CSS. The difference between them is - div is a block element and comes with line breaks, span is inline.
          • DHTML is Dynamic HTML.
            • DHTML is a way for you to change the way your pages look. You can instantly change the color of a page with the click of the mouse or without the click of a mouse. You can cause things to happen just by moving the mouse around the page.
            • Combination of HTML and Client side scripting like Java Script.
          • Title attribute is used for showing tip text/extra information. Following are some example:
          <a href="http://princekapoor82.blogspot.com" title="OAF Blog">Prince Kapoor Blog</a>
          <abbr title="Oracle Applications Self Service Framework">OAF</abbr>
          <p title="Oracle Applications Self Service Framework Training">OAF Training</p>

          •  <IMG> tag should contain alt, width and height attribute. Text in alt will be displayed if image can't be displayed. width and height attribute make the page render faster on the browser.
          • <!DOCTYPE>
            • The <!DOCTYPE> declaration must be the very first thing in your HTML document, before the <html> tag.
            • The <!DOCTYPE> declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.
            •  Following are the examples:
               For HTML 5:-
              <!DOCTYPE html>

              For HTML 4.1 Strict:-
              <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

              HTML 4.01 Transitional:-
              <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
            •  DOCTYPE indicates we are specifying the document type.
            •  HTML means HTML is the root(first) element in your page.
            •  PUBLIC means standard is publicly available.
            •  "-//W3C//DTD HTML 4.01 Transitional//EN" indicates the exact version of that HTML.
            •  "http://www.w3.org/TR/html4/loose.dtd" indicates the file that identifies the particular standard. 
          • http://princekapoor82.blogspot.com or  http://princekapoor82.blogspot.com/ will cause the server to look for a default file. The URL will change to http://princekapoor82.blogspot.com/index.html or http://princekapoor82.blogspot.com/default.htm depending on the web server.