CSS Value String

A String in CSS is a text value assigned to a property. Strings are a sequence of characters enclosed in either single or double quotes.

Example:
'GeeksForGeeks' is a String
"GeeksForGeeks" is a String

quotes inside a string are not allowed and needs to be escaped with a \ like “this is a \”(double quote) “.

All text values other than the CSS keywords that are enclosed in double-quotes or single quotes are considered as strings in CSS. 

For example: 

content property in CSS takes in a String (contents to be inserted) as value.



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
<head>
<style>
    #insert:after{
        content: "Welcome to GeeksForGeeks";
    }
</style>
</head>
<body>
<h1>
    CSS Value/ String
</h1>
<div id="insert">
</div>
</body>
</html>

chevron_right


Output:

Another example would be to assign background image. The URL to the background image would be enclosed in a double quote which indicates that the background-image property takes in a string value

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
<head>
<style>
body  {
  background-image: url("geeksforgeeks.png");
  background-color: #cccccc;
}
</style>
</head>
<body>
<h1>CSS Value/String</h1>
</body>
</html>

chevron_right


Output:




My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.