Is it possible that elements between CSS3 can also be styled? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is it possible that elements between CSS3 can also be styled?

25th Nov 2019, 10:01 AM
Sandro Cottas
Sandro Cottas - avatar
10 Answers
+ 6
Shouldn't all content on a web page including the example text between paragraphs be marked up with semantic, (descriptive and meaningful) HTML elements in the first place? and secondly, yes, because that also simplifies and clarifies styles?
25th Nov 2019, 6:11 PM
Lisa F
Lisa F - avatar
+ 6
harsh vardhan tripathi to complement what David Carroll and Lisa F said it is bad practice to write text outside html elements, and your code will look messy too, plus it will be much harder to style your document without proper structure. Best practice is to put every text in the proper elements. HTML 5 added new elements to help you, you can read more here; https://www.w3schools.com/html/html5_semantic_elements.asp
25th Nov 2019, 7:11 PM
Robin R.
Robin R. - avatar
+ 6
Robin R. and Lisa F Indeed... The example Ipang used to better understand the question is one that would qualify as highly unusual and certainly considered to be bad practice. The issue with that example is the free text is adjacent to block elements containing a similar structure of text. In this case, there really isn't any reason for the free text to NOT be wrapped within a semantic block element as well. On the other hand, had the example used inline elements, this would qualify as a valid and quite common use case. Examples would be when using <strong>, <em>, <a>, <span>, <img>, etc. You really <strong>can't</strong> escape this mixing of <a href="#"> <span> <em>content</em> types </span> </a>. In this context, there wouldn't be anything wrong with this question. 😉
25th Nov 2019, 9:07 PM
David Carroll
David Carroll - avatar
+ 5
harsh vardhan tripathi The non-element text between its sibling <p> tags are technically wrapped within a parent element. Therefore, all non-element text will be styled according to the styles applied to their parent element. However, be aware that the same styles applied to the parent element will, by default, cascade to all child elements, which will include the sibling <p> tags. Therefore, if a specific style should only apply to the non-element text in between, that text should be wrapped in its own element.
25th Nov 2019, 5:33 PM
David Carroll
David Carroll - avatar
+ 3
<p>This is paragraph 1</p> This text lies in between two paragraphs <p>This is paragraph 2</p> You mean you want to style the "This text lies in between two paragraphs" part?
25th Nov 2019, 11:16 AM
Ipang
+ 2
What exactly do you mean? Example?
25th Nov 2019, 10:17 AM
Robin R.
Robin R. - avatar
+ 1
Not really sure, but AFAIK you will need to wrap it in something, like a <span> or <div> or something. It's the text container (span, div) whom will be styled eventually.
25th Nov 2019, 2:50 PM
Ipang
0
I mean, can we style between text of paragraphs by css3
25th Nov 2019, 10:20 AM
Sandro Cottas
Sandro Cottas - avatar
0
Yes exactly
25th Nov 2019, 1:48 PM
Sandro Cottas
Sandro Cottas - avatar
0
The background-clip property defines how the background of an item (whether image or color) extends under the border box, the padding box, or the content box
5th Dec 2019, 11:24 PM
Ahmed Belkhodja