Swift: Optional variable

This entry is part 35 of 41 in the series Swift

For Swift, when you declare a variable, you need to provide an initial value.  If the value is unknown, you can declare it as an optional.

var name:String?

//name = "abcde"

if name != nil {
    print("Your name: \(name!)")
} else {
    print("There is no value in the Name")


CSS3 Selectors: :required & :optional

This entry is part 23 of 40 in the series CSS3 Selectors

We might want to highlight a form field where the users will have to fill up.


Applies to form controls that have the <required> attribute set.


Applies to all form controls that do not have the <required> attribute.

Quick contact form

<!DOCTYPE html>
<html lang='en'>
    <meta charset='utf-8'>
    <title>Quick contact form</title>
        input:required {
            border: 1px solid red;
        input:optional {
            border: 1px solid blue;
        <legend>Contact information</legend>
                <label for='email'>Email:</label>
                <input required type='email' id='email' name='email'/>
                <label for='tel'>Telephone number:</label>
                <input type='tel' id='tel' name='tel'/>
                <label for='url'>Website:</label>
                <input type='url' id='url' name='url'/>
        <input type='submit' value='Submit this' />