package require Tk
canvas .c
# On canvases, tags are known only if at least one item has it
foreach i {1 2 3 4 5} {
.c create rect [expr $i*10] 0 [expr $i*10+8] 8 -tag box
} ;# create multiple canvas objects
.c itemconfig box -fill red ;# to change their color
.c lower box ;# to hide them behind a background area
pack .c
text .t
# On text widgets, tags persist even without instances
# You should configure them early, to avoid lengthy reformatting
.t tag config bold -font {helvetica 12 bold}
.t tag config hilite -background orange
.t insert end Hello
.t insert end world bold ;# tags come as 4(6,8..)th element
.t insert end "out there" {bold hilite}
.t tag config bold -font {times 11 bold} ;# change and reformat all
pack .tNote: Use the full names for foreground and background. In the tag config context fg means fgstipple and bg means bgstipple.[tutorials][examples in books, including Effective, JO's, ...]
"Tagging passages of text or canvas objects makes it possible to apply formatting to or recognize events from the whole collection... with a concise syntactic specification... not heaps of application specific code." Jon Fernquest [1]

