CSS(Cascading Style Sheets)
https://www.oxfordwebstudio.com/user/pages/06.da-li-znate/sta-je-css/sta-je-css.png

CSS(Cascading Style Sheets)

Cascading Style Sheets (CSS) is a style sheet language used for specifying the presentation and styling of a document written in a markup language such as HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript.

CSS is designed to enable the separation of content and presentation, including layout, colors, and fonts. This separation can improve content accessibility, since the content can be written without concern for its presentation; provide more flexibility and control in the specification of presentation characteristics; enable multiple web pages to share formatting by specifying the relevant CSS in a separate .css file, which reduces complexity and repetition in the structural content; and enable the .css file to be cached to improve the page load speed between the pages that share the file and its formatting.

Separation of formatting and content also makes it feasible to present the same markup page in different styles for different rendering methods, such as on-screen, in print, by voice (via speech-based browser or screen reader), and on Braille-based tactile devices. CSS also has rules for alternate formatting if the content is accessed on a mobile device.

The name cascading comes from the specified priority scheme to determine which declaration applies if more than one declaration of a property match a particular element. This cascading priority scheme is predictable.

The CSS specifications are maintained by the World Wide Web Consortium (W3C). Internet media type (MIME type) text/css is registered for use with CSS by RFC 2318 (March 1998). The W3C operates a free CSS validation service for CSS documents.

In addition to HTML, other markup languages support the use of CSS including XHTML, plain XML, SVG, and XUL. CSS is also used in the GTK widget toolkit.


History

CSS was first proposed by H?kon Wium Lie on 10 October 1994. At the time, Lie was working with Tim Berners-Lee at CERN. Several other style sheet languages for the web were proposed around the same time, and discussions on public mailing lists and inside World Wide Web Consortium resulted in the first W3C CSS Recommendation (CSS1) being released in 1996. In particular, a proposal by Bert Bos was influential; he became co-author of CSS1, and is regarded as co-creator of CSS.


Syntax

CSS has a simple syntax and uses a number of English keywords to specify the names of various style properties.


Style sheet

A style sheet consists of a list of rules. Each rule or rule-set consists of one or more selectors, and a declaration block.


Selector

"CSS class" redirects here. For non-CSS use of element classes in HTML, see class attribute (HTML).

In CSS, selectors declare which part of the markup a style applies to by matching tags and attributes in the markup itself.


Selector types

Selectors may apply to the following:

  • all elements of a specific type, e.g. the second-level headers h2
  • elements specified by attribute, in particular:id: an identifier unique within the document, denoted in the selector language by a hash prefix e.g. #idclass: an identifier that can annotate multiple elements in a document, denoted by a dot prefix e.g. .classname (the phrase "CSS class", although sometimes used, is a misnomer, as element classes—specified with the HTML class attribute—is a markup feature that is distinct from browsers' CSS subsystem and the related W3C/WHATWG standards work on document styles; see RDF and microformats for the origins of the "class" system of the Web content model)
  • elements depending on how they are placed relative to others in the document tree.

Classes and IDs are case-sensitive, start with letters, and can include alphanumeric characters, hyphens, and underscores. A class may apply to any number of instances of any element. An ID may only be applied to a single element.


Pseudo-classes

Pseudo-classes are used in CSS selectors to permit formatting based on information that is not contained in the document tree.

One example of a widely used pseudo-class is :hover, which identifies content only when the user "points to" the visible element, usually by holding the mouse cursor over it. It is appended to a selector as in a:hover or #elementid:hover.

A pseudo-class classifies document elements, such as :link or :visited, whereas a pseudo-element makes a selection that may consist of partial elements, such as ::first-line or ::first-letter. Note the distinction between the double-colon notation used for pseudo-elements and the single-colon notation used for pseudo-classes.


Consider this HTML fragment:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <style>
            #xyz { color: blue; }
        </style>
    </head>
    <body>
        <p id="xy" style="color: green;">To demonstrate specificity</p>
    </body>
</html>        


Combinators

Multiple simple selectors may be joined using combinators to specify elements by location, element type, id, class, or any combination thereof. The order of the selectors is important. For example, div .myClass {color: red;} applies to all elements of class myClass that are inside div elements, whereas .myClass div {color: red;} applies to all div elements that are inside elements of class myClass. This is not to be confused with concatenated identifiers such as div.myClass {color: red;} which applies to div elements of class myClass.

要查看或添加评论,请登录

Sivaganesh M的更多文章

  • Cloud Computing

    Cloud Computing

    Nowadays, Cloud computing is adopted by every company, whether it is an MNC or a startup many are still migrating…

  • Full Stack Development

    Full Stack Development

    Full Stack Development refers to the development of both front end (client side) and back end (server side) portions of…

    2 条评论
  • JavaScript - A Scripting Language

    JavaScript - A Scripting Language

    JavaScript often abbreviated as JS, is a programming language and core technology of the Web, alongside HTML and CSS…

  • HTML (Hypertext Markup Language)

    HTML (Hypertext Markup Language)

    Hypertext Markup Language (HTML) is the standard markup language for documents designed to be displayed in a web…

  • Design and Analysis of Algorithms

    Design and Analysis of Algorithms

    Is a fundamental aspect of computer science that involves creating efficient solutions to computational problems and…

  • DATA VISUALIZATION - tableau

    DATA VISUALIZATION - tableau

    Introduction to Data Visualization using Tableau Our goal as Data Analysts is to get the insights from our data in such…

  • OPERATING SYSTEM

    OPERATING SYSTEM

    Operating System lies in the category of system software. It basically manages all the resources of the computer.

  • GITHUB Copilot

    GITHUB Copilot

    GitHub Copilot is a code completion tool developed by GitHub (owned by Microsoft) and OpenAI (49% owned by Microsoft)…

  • Database Management System (DBMS)

    Database Management System (DBMS)

    Database Management Systems (DBMS) are software systems used to store, retrieve, and run queries on data. A DBMS serves…

  • Web 3.0 : The Evolution of Web

    Web 3.0 : The Evolution of Web

    The third generation of the internet has now firmly taken hold in the modern retelling of Web history. Web 3.

社区洞察

其他会员也浏览了