CSS and HTML Complex Attribute Selectors Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

CSS and HTML Complex Attribute Selectors Tutorial

CSS and HTML Complex Attribute Selectors Tutorial

In the spirit of CSS itself, as the study of Cascading Style Sheets, we want to add an โ€œonion layerโ€ on top of what we started doing back at CSS and HTML Complex Selectors Primer Tutorial as shown below, today. That โ€œonion layerโ€, in our โ€œonions of the 4th dimensionโ€ feeling here, relates to HTML element attributes โ€ฆ

Attributes provide additional information about HTML elements.

All HTML elements can have attributes
Attributes provide additional information about an element
Attributes are always specified in the start tag
Attributes usually come in name/value pairs like: name=โ€valueโ€

Now, as you can imagine, there is no end to the level of (fine) granularity of โ€œselectionโ€ this gives you as a tool, in relation to picking out really specific subsets of HTML (elements) for your CSS styling attention. Perhaps the most everyday HTML element with important โ€œattributesโ€ that we can think of, is the HTML a tag, as a link to โ€œsomewhereโ€ โ€ฆ though โ€œsomewhereโ€ can also be โ€œnowhereโ€ โ€ฆ chortle, chortle โ€ฆ and todayโ€™s work replaces the HTML p (child) element types of the previous tutorial and replaces them with HTML a (child) element types, for our purposes today.

If you clicked that last link youโ€™d have seen a myriad of HTML a tag โ€œattributeโ€ possibilities for you to think about โ€ฆ at the time of writing, namely โ€ฆ

  • charset
  • coords
  • download
  • href
  • hreflang
  • media
  • name
  • rel
  • rev
  • shape
  • target
  • type

โ€ฆ which seems like a lot of scope for (fine granular selector) definition. However, this โ€œattributeโ€ selection does not apply to inferred default values. In other words, if the default target=โ€_selfโ€ is not actually written in your HTML for a given HTML a tag that you want to hone in on for particular styling, donโ€™t expect CSS like a[target=โ€_selfโ€] { font-weight: bold; } to catch these, as this โ€œattributeโ€ selector CSS only applies to specifically defined and โ€œattributedโ€ HTML.

And so, today, we have links to โ€ฆ

โ€ฆ for your perusal, and thought. Once again, thanks to this wonderful inspiring link.

Did you know?

As you might suspect there is a โ€œcontainsโ€ way to define โ€œattributeโ€ selectors. Where we have, today โ€ฆ



a[href="//www.rjmprogramming.com.au"]

โ€ฆ we could widen its scope (of cover) via the โ€œcontainsโ€ version โ€ฆ



a[href*="rjmprogramming.com.au"]

โ€ฆ to cover any URL from this domain.



Previous relevant CSS and HTML Complex Selectors Primer Tutorial is shown below.

CSS and HTML Complex Selectors Primer Tutorial

CSS and HTML Complex Selectors Primer Tutorial

Today, as with WordPress 4.1.1โ€™s CSS and HTML Complex Selectors Primer Tutorial, we want to delve deeper into the less obvious aspects of CSS, encouraged as we were to find this wonderful inspiring link โ€ฆ thanks. But hold off on the โ€œbounceโ€ now, because we are value adding the wonderful information from the link with practical and self explanatory HTML and CSS web applications that all show โ€ฆ

  • CSS involved โ€ฆ is inline CSS shown and available in the HTML programming source you can optionally download โ€ฆ and โ€ฆ
  • HTML subset of relevance that the CSS acts on โ€ฆ above โ€ฆ
  • The resultant HTML webpage result

โ€ฆ all these three components on the one webpage, to help with โ€œcause and effectโ€ regarding these more complex CSS concepts. Perhaps, that way, theyโ€™ll โ€œsink inโ€ quite well?!

So what โ€œComplex Selectorโ€ types are we trying to highlight in todayโ€™s web application โ€ฆ

  1. Direct Child โ€ฆ child in parent/child relationship โ€ฆ (Todayโ€™s) eg. article > p { โ€ฆ }
  2. General Sibling โ€ฆ elements at the same hierarchical layer โ€ฆ (Todayโ€™s) eg. h2 ~ p { โ€ฆ }
  3. Adjacent Sibling โ€ฆ first elements at the same hierarchical layer โ€ฆ (Todayโ€™s) eg. h2 + p { โ€ฆ }

Knowing about some of these more esoteric selectors could help you pinpoint specific elements within complex โ€œcontainerโ€ elements, we hope you get out of todayโ€™s work.

So this leaves us leaving you with links to โ€ฆ

โ€ฆ and weโ€™ll get back to you with more CSS of this ilk as time goes on.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Tutorials and tagged , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *