Listing 5.1 on page 70 of SAMS Teach Yourself HTML and CSS in 24 Hours reveals the source code for a web page depicting a Dorothy Parker poem. The poem’s three stanzas are aligned diagonally across the page, while its title and author are centered above it.
The code uses internal attributes to realize this alignment; there is no necessity for the code to go search for alignment instructions on a style sheet. (Does code search? I have always found the anthropomorphisizing of technology disconcerting; the code doesn’t “want” to do anything.)
In the process of creating my sample unordered list, I used the “div” tag in order to center my main heading. The “div” tag is convenient in that it delineates a sub area of text to receive formatting. I then realized that I had other headings within the body of my document that I wanted centered but they were surrounded by alternating blocks of text that were left-aligned. I dreaded the task of adding a “div” tag every time – a clunky solution.
Thankfully I had designated each of these headings to the same tag, “h1,” so I just added a “text-align” tag to the code in my linked style sheet with the result that all the headings snapped in place.
I’m sure there’s a better way to do it but I was thrilled that it worked nonetheless.
All of this reminds me of a Steve Martin routine that pops into my head from time to time – plumber’s convention – it’s not on You Tube unfortunately.