Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling tags within tags confusion

Tags:

css

I am having a rather difficult time understanding this type of css selector show below, or at least how to apply.

p .intro a { color: yellow }
like image 212
user1762554 Avatar asked Nov 02 '12 02:11

user1762554


People also ask

Should I use custom HTML tags?

Custom HTML tags are completely valid markup, they are supported by all browsers and should be considered best practice. If you can benefit from the many features of custom elements and there aren't any existing HTML tags that are a better fit for your purpose, then it's recommended to use them. Are Custom Tags Better Than Divs?

How do you know if a tag is standard or custom?

A simple Google check will verify if a tag is standard or custom. Using custom tags with or without javascript makes the document more readable. Which is the point you were making. Not everything needs to be predefined. If it were the language would never have evolved in the first place.

What are the different types of formatting tags?

The formatting tags are divided into two groups: physical tags, that are used to style the text (visual appearance of the text) and logical or semantic tags that add semantic value to the text parts (e. g., inform search engines for which keywords a web page should be ranked). Let’s dive deeper and talk about formatting tags in details.

Which tag defines emphasized text with added semantic importance?

The <em> tag defines emphasized text, with added semantic importance. <!DOCTYPE html> <html> <body> <p> This is a paragraph </p> <p> The important part of the text is defined <em> in italic </em>. </p> <p><i> Lorem ipsum </i>, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. </p> </body> </html>


2 Answers

p .intro a { color: yellow }

It would style any (reading from right to left)

  • a tag
  • which is a descendant of any tag with a class (dot is a class selector) intro
  • which is a descendant of p tag

Example (note that the elements are not direct children, but descendants):

<p>
    <span>
        <span class="intro">
            <span>
                <a href="#">I am yellow</a>
            </span>
        </span>
    </span>
</p>

(fiddle)

like image 164
valentinas Avatar answered Nov 15 '22 01:11

valentinas


This selector would match HTML similar to this:

<p>
    <span class="intro">
        <a href="#">I am yellow</a>
    </span>
</p>

Basically, a a tag inside of a tag with a class of intro inside of a p tag. They don't have to be direct children.

like image 21
Blender Avatar answered Nov 15 '22 00:11

Blender