CSSID

From Liberty BASIC Family
Jump to navigation Jump to search
Not supported in Just BASIC Not supported in Liberty BASIC Not supported in Liberty BASIC 5 Supported in Run BASIC

Description

Run BASIC gives us the ability to format the display of the pages in our programs. The possibilities are nearly endless, so please read the article, Styling with CSS, to start learning about the many things you can do with the CSSID statement.

Syntax

  1. CSSID #tag, ruleExpr$ - Define a CSS id rule with #tag and ruleExpr$

Hints

Cascading Style Sheets (CSS) is a style language that defines the layout of one or more sections of HTML documents. Background colors, font colors and types, and image layering are just some of the special effects that can be achieved using CSS and Run BASIC. The CSS layout is defined using the CSSID command. Each CSS layout is given a unique name. Run BASIC then uses the DIV command to assign sections of the defined CSS layout.
A typical CSSID statement looks like this:
CSSID #CoolColor, " { Background-Color: yellow } "
To apply the style to an outputted section of a web page, use the DIV and END DIV statements, like this:
DIV CoolColor
    PRINT "Text displayed on color."
END DIV

The text in the code between DIV and END DIV is in the style specified in the CSSID statement. Notice that you must give the style a name that begins with a # character, but you do not use that character when issuing the DIV statement. The CSSID is "#CoolColor" and the DIV statement specifies "CoolColor".

Example

Here is a tiny demo. The output from the code looks like this:

html "</div><div>"

CSSID #CoolColor, " { Background-Color: yellow } "
 
DIV CoolColor
    PRINT "Text displayed on color."
END DIV

print "Text outside of DIVs."

CSSID #CoolBorder, " { Border-Style: Inset } "

DIV CoolBorder
    print "Text inside a border."
END DIV

Useful Procedures

' Place a useful function or sub using this keyword here