Jump to content

Cascading Style Sheets: Difference between revisions

From Simple English Wikipedia, the free encyclopedia
Content deleted Content added
m Reverted edits by 24.16.142.236 (talk) to last version by 24.246.28.27
Undid revision 9489340 by 2A01:4B00:878B:8C00:28F3:70B4:AF55:5ED4 (talk)
Tag: Undo
 
(43 intermediate revisions by 26 users not shown)
Line 1: Line 1:
[[Image:CSS3 logo and wordmark.svg|thumb|150px|The logo for CSS 3]]
{{Update|inaccurate=yes}}
'''Cascading Style Sheets''', or '''CSS''', is a way to change the look of [[HTML]] and [[XHTML]] web pages. CSS was designed by the [[W3C]], and is supported well by most modern [[web browser]]s. The current version of CSS is CSS3. CSS4 is available, but is split into parts.


One advantage to using CSS is a [[Webpage|web page]] can still be displayed, even if the CSS is not working or removed.
'''Cascading Style Sheets''', or '''CSS''', are a way to change the look of [[HTML]] and [[XHTML]] web pages. CSS was designed by the [[W3C]], and is supported well by most modern [[web browser]]s. The current version of CSS is CSS 2. CSS version 3 is currently being worked on. It will introduce new properties like <code>border-radius</code>.


CSS code is saved in files with the <tt>.css</tt> [[file extension]].
One advantage to using CSS is a web page can still be displayed and understood, even if the CSS is not working or removed.


To import a CSS file you would use <code><link rel="stylesheet" href="CSS_FILE_NAME_HERE.css"></code> or for a folder you would use <code><link rel="stylesheet" href="FOLDER_NAME_HERE/CSS_FILE_NAME_HERE.css"></code> in HTML.
CSS code is saved in files with the <tt>.css</tt> file extension.

In CSS you would use <code>@import url("CSS_FILE_NAME_HERE.css");</code> or for a folder you would use <code>@import url(FOLDER_NAME_HERE/CSS_FILE_NAME_HERE.css");</code> to import CSS into your CSS.

You could also use <code>@import</code> in a set of <code><style>import goes here</style></code> tags to import the CSS in your HTML from your CSS. You could also put your CSS directly into the HTML by putting in a set of <code><style>css here</style></code> tags.

== CSS Examples ==

=== Paragraphs ===


== Example CSS ==
To make all paragraphs on a page blue and sized 20% bigger than normal text, we would apply this CSS rule to a page:
To make all paragraphs on a page blue and sized 20% bigger than normal text, we would apply this CSS rule to a page:


<source lang="css">
<syntaxhighlight lang="css">
p {
p {
color: blue;
color: blue;
font-size: 120%;
font-size: 120%;
background-color: white
}
}
</syntaxhighlight>
</source>
The <code>p</code> refers to all [[HTML]] elements with the <code><nowiki><p></nowiki></code> tag. The CSS is being used to change this element. The <code>color</code> and <code>font-size</code> are both properties and the <code>blue</code> and <code>120%</code> are values. Each property has a set of possible values. These values can be words or numbers.

=== Main Title ===

To give the main Title on a page a solid red border underneath, we would apply this CSS rule to the page. 5px otherwise known as [[pixel]]s, represents the thickness of the line:

<syntaxhighlight lang="css">
h1 {
border-bottom: 5px solid red;
}
</syntaxhighlight>The <code>h1</code> refers to all [[HTML]] elements with the <code><nowiki><h1></nowiki></code> tag. The CSS is being used to change this element. The <code>border-bottom</code> is the property and the <code>5px</code> and <code>solid red</code> are values. Each property has a set of possible values. These values can be words or numbers.

=== Button ===
To give a button a hover effect and make it blue with no border, we would apply this CSS rule to this page. The CSS is being used to change this element. The button refers to all [[HTML]] elements with the <button> tag. <syntaxhighlight lang="css">
button:hover {
padding:25px 35px;
}

button {
display: block;
color: white;
border:0px;
transition:0.3s;
text-align: center;
padding: 20px 27px;
text-decoration: none;
background-color: rgb(0, 150, 255);
border-radius: 15px;
font-size:18px;
}
</syntaxhighlight>Preview with the HTML code <code><button> button </button></code> used:
[[File:Button made in css.png|frameless]]

Preview of the button being hovered over:

[[File:Button made in css (hovered).png|frameless]]


== Other websites ==
== Other websites ==
* [http://w3.org/Style/CSS W3C]
* [http://w3.org/Style/CSS W3C]
* [http://css3.info Website about CSS3]
* [http://css3.info Website about CSS3]
* [http://www.yourhtmlsource.com/stylesheets/ HTML Source: Beginner's CSS Tutorials] - a site of tutorials aimed at web design beginners.

{{Tech-stub}}


[[Category:Programming languages]]
[[Category:Programming languages]]
[[Category:Web design]]



[[mk:CSS селектори]]
{{Tech-stub}}

Latest revision as of 22:41, 25 May 2024

The logo for CSS 3

Cascading Style Sheets, or CSS, is a way to change the look of HTML and XHTML web pages. CSS was designed by the W3C, and is supported well by most modern web browsers. The current version of CSS is CSS3. CSS4 is available, but is split into parts.

One advantage to using CSS is a web page can still be displayed, even if the CSS is not working or removed.

CSS code is saved in files with the .css file extension.

To import a CSS file you would use <link rel="stylesheet" href="CSS_FILE_NAME_HERE.css"> or for a folder you would use <link rel="stylesheet" href="FOLDER_NAME_HERE/CSS_FILE_NAME_HERE.css"> in HTML.

In CSS you would use @import url("CSS_FILE_NAME_HERE.css"); or for a folder you would use @import url(FOLDER_NAME_HERE/CSS_FILE_NAME_HERE.css"); to import CSS into your CSS.

You could also use @import in a set of <style>import goes here</style> tags to import the CSS in your HTML from your CSS. You could also put your CSS directly into the HTML by putting in a set of <style>css here</style> tags.

CSS Examples

[change | change source]

Paragraphs

[change | change source]

To make all paragraphs on a page blue and sized 20% bigger than normal text, we would apply this CSS rule to a page:

p {
color: blue;
font-size: 120%;
background-color: white
}

The p refers to all HTML elements with the <p> tag. The CSS is being used to change this element. The color and font-size are both properties and the blue and 120% are values. Each property has a set of possible values. These values can be words or numbers.

Main Title

[change | change source]

To give the main Title on a page a solid red border underneath, we would apply this CSS rule to the page. 5px otherwise known as pixels, represents the thickness of the line:

h1 {
border-bottom: 5px solid red;
}

The h1 refers to all HTML elements with the <h1> tag. The CSS is being used to change this element. The border-bottom is the property and the 5px and solid red are values. Each property has a set of possible values. These values can be words or numbers.

To give a button a hover effect and make it blue with no border, we would apply this CSS rule to this page. The CSS is being used to change this element. The button refers to all HTML elements with the <button> tag.

    button:hover {
padding:25px 35px;
}

button {
 display: block;
  color: white;
border:0px;
  transition:0.3s;
  text-align: center;
  padding: 20px 27px;
  text-decoration: none;
  background-color: rgb(0, 150, 255);
  border-radius: 15px;
  font-size:18px;
}

Preview with the HTML code <button> button </button> used:

Preview of the button being hovered over:

Other websites

[change | change source]