|
|
HTML Code TutorialTutor Ebook Download Style SheetsThe use of Style Sheets can save a lot of time in the process of building HTML pages. This is the main advantage of using them since actual page attributes are determined by the visiting browser. Also, the old inline method of assigning fonts to paragraphs and other page structures added a considerable amount of extra code to a page. Extra code means larger pages and greater bandwidth consumption. Faster building and smaller pages make the time invested in learning to use style sheets worthwhile. MethodsThere are 3 methods of using style sheets in HTML documents. They are, linked , embedded and inline. Linked style sheets are placed in a separate text file and accessed each time a web page is opened. Embedded style sheets are placed in the head section of the HTML page and can over ride linked settings. Inline style sheets are much like the old method of assigning font attributes. They are placed in the actual lines of code and can over ride both linked and embedded style sheet settings. There are some HTML tags that require the inline method to work properly. Style Sheet ConstructionNo matter what method is used, the basic structure of an individual style sheet setting is the same. Each line of a style sheet is made up of 2 parts: selector and declaration
The declaration also contains 2 parts separated by a colon which acts as an equal sign. A few attributes with values which can be set using Style Sheets are:
An example of each setting is shown in the style sheet shown below. Notice that each individual declaration is separated by a semi-colon. |
Contents Table of ContentsIntroduction Page Structure Basic HTML PageDoctype The Body Tag The Header Tag The Division Tag Horizontal Rule Anchor Tag Anchor Tag - Intradocument Anchor Tag - Image Using Borders The ID Attribute Meta Tags Text Controls Style SheetsWorking With Fonts The Paragraph Tag Paragraphs-Images Using Lists The Pre Tag Line Break Tag Tables Basics of TablesColspan Forms Form BasicsCheck Boxes Text Boxes Selection Boxes Frames Basic FramesTarget and Scrolling Search Engines Miscellaneous Buttons with CSSUsing Color Color Chart Using Images Using Templates Uploading HTML pages. HTML-CSS Quizzes |
p{ font-family: Arial, sans-serif;font-style : normal ;font-size : 10pt; font-weight :normal;text-align :left; color :#000000;background-color :#FFFFFF; text-indent : 1em;padding-bottom : 3em}
NOTE: Color can be specified by name (blue), hexidecimal code (#0000ff) or RGB code (#00f). To keep your Style Sheets CSS2 compliant follow 2 simple rules.
Generic Font Families
The browser defaults to the generic choice when a declared font is not available on a surfer's machine. Once you develop a desired look for your pages using the style tag, save it in Notepad and paste it into each document that you build. Or include the style sheet settings in your templates. This will also help to produce consistency in your pages. Linked Style SheetsLinked style sheets are placed in a separate text file and saved in the root directory. The file is saved with a css extension. The link to the file is placed in the head section of each document. Code in Head Section: Inline Style SheetsInline style sheets will over ride both linked and embedded settings. Certain tags like the span tag work best with Inline settings. Code placement is similar to the old method.
Embedded Style SheetsEmbedded style sheets are placed in the head section within a set of style tags. Example Code: For more information on style sheet techniques, study the source code of the documents in our free web template gallery. You can Test Code online in this: HTML editor
|
|
|
|
CGI Online |