Skip to content
Related Articles

Related Articles

Improve Article

CSS Value String

  • Last Updated : 07 Sep, 2020
Geek Week

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.






<!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>

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




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

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :