zoukankan      html  css  js  c++  java
  • CSS Properties and CSS Rules

    Table of Contents

    You style HTML elements via CSS properties. Different HTML elements may have different CSS properties you can set. CSS properties can be organized into CSS rules. A CSS rule groups a set of CSS properties together, and applies all properties to the HTML elements matched by the CSS rule. Both CSS properties and CSS rules will be covered in detail in this text.

    CSS Properties

    CSS property styles an aspect of an HTML element. Here are a few examples:

    <div style="border: 1px solid black;
                font-size: 18px; "> Style This </div>
    

      

    In this example two CSS properties are applied to the div element: The border and the font-size properties.

    A CSS property declaration consists of a property name and a property value. The property name comes first, then a colon, and then the value. Here is the general pattern a CSS property declaration follows:

    property-name : property-value
    

      

    If you specify more than one CSS property, the each name - value pair is separated by a semicolon, like this:

    property1 : property-value1;
    property2 : property-value2;
    

      

    The last property declaration does not have to end with a semicolon, but it makes it easier to add more CSS properties without forgetting to put in that extra semicolon.

    There are many CSS properties you can specify for different HTML elements. These CSS properties are covered in their own texts.

    CSS Rules

    CSS rule is a grouping of one or more CSS properties which are to be applied to one or more target HTML elements.

    A CSS rule consists of a CSS selector and a set of CSS properties. The CSS selector determines what HTML elements to target with the CSS rule. The CSS properties specifies what to style of the targeted HTML elements.

    Here is a CSS rule example:

      div {
          border    : 1px solid black;
          font-size : 18px;
      }
    

      

    This example creates a CSS rule that targets all div elements, and the set the CSS properties border andfont-size for the targeted elements.

    The CSS selector part a CSS rule is the part before the first {. In the example above it is the div part of the CSS rule. The CSS properties are listed inside the { ... } block.

    CSS rules have to be specified inside either a style element or inside an external CSS file.

  • 相关阅读:
    MPF源码分析之资源文件加载
    oracle存储过程代码日志记录
    fix8源码分析之日志模块
    oracle日期转整数
    记录OCI操作一个诡异的问题
    记录一个虚拟机重启网络启动失败问题
    buff占用内存高
    MFC程序编译链接问题汇总一
    回调函数模型设计
    利用call与apply向函数传递参数
  • 原文地址:https://www.cnblogs.com/hephec/p/4564443.html
Copyright © 2011-2022 走看看