|  01-30-2016, 04:22 PM | #1 | 
| Member  Posts: 11 Karma: 10 Join Date: Jan 2016 Device: none |  Questions about SPAN and DIV using CSS 
			
			Hi, I'm at a bit of a standstill with my epub in Sigil. I suspect it's more tunnel vision than not. I'm about done with formatting my book in Sigil, however another problem has reared it's ugly head. I have 36 html sections and 3 external CSS. SS#1 is strictly for headings (H1,H2, etc.), SS#2 is for the majority of my paragraph styling (which is align:justified), and SS3 is only for sections that have all content centered. I did it this way to simplify things in my head. So, my problem deals with the last html section where I have SS1 and SS2 linked. Besides the header and paragraph content, I have a link at the bottom that I wanted centered on the page. I decided use SPAN to do  inline styling without creating a line break, since it's just the one line. I added this to SS2: } span.link { text-align: center; } And this to my code: <p><a href="http://www.overmyheadwithCSS.com/gp/product/B016S96QEA">span class="link"><View on Headcase.com</span></a></p> ...and nothing changed. So I removed "span" from the "span.link" on CSS, thinking I was applying it wrong. But still no centered link. Then I used this: } div.link { text-align: center; } and changed my code to: <p><a href="http://www.overmyheadwithCSS.com/gp/product/B016S96QEA">div class="link"><View on Headcase.com</div></a></p> and VIOLA! The link was centered! But now Sigil validation gives me this error: element 'div' is not allowed for content model '(br|span|bdo|map|object|img|svg|tt|i|b|big|small| em|strong|dfn|code|q|samp|kbd|var|cite|abbr|acrony m|sub|sup|input|select|textarea|label|button|ins|d el|script)' I'm really new to this and it's been a crash course of bleary eyes and spontaneous profanity. I think this is a simple fix, but I'm too simple to understand? Shouldn't "span" work "inside" a style? | 
|   |   | 
|  01-30-2016, 04:59 PM | #2 | 
| Well trained by Cats            Posts: 31,249 Karma: 61360164 Join Date: Aug 2009 Location: The Central Coast of California Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A | 
			
			Div is a Block level and  can not contain another block Are you trying to style the 'text'? Simply apply the style to the <p | 
|   |   | 
| Advert | |
|  | 
|  01-30-2016, 05:00 PM | #3 | 
| Sigil Developer            Posts: 9,071 Karma: 6361556 Join Date: Nov 2009 Device: many | 
			
			If the entire paragraph is just the link to be centered, have you thought about adding the css and link class to that final p tag.  Or replace the p tag with a div.  But trying to centre some span tag in the middle of a p tag is not a good idea.
		 | 
|   |   | 
|  01-30-2016, 05:12 PM | #4 | 
| Member  Posts: 11 Karma: 10 Join Date: Jan 2016 Device: none | 
			
			Div is a Block level and can not contain another block Are you trying to style the 'text'? Simply apply the style to the <p __________________________________________________ ____________________ Thanks, TheDucks. The Div rule is good to know. That explains the error. By applying the style to the p, do you mean "align-text: centered" in the p tag? I had to wipe a ton of "attribute "align" not declared for element "p" statements from the document, even though it was in my stylesheet. Last edited by KingAuthor; 01-30-2016 at 05:18 PM. Reason: Forgot quote | 
|   |   | 
|  01-30-2016, 05:16 PM | #5 | 
| Member  Posts: 11 Karma: 10 Join Date: Jan 2016 Device: none | 
			
			Thanks, KevinH. Wouldn't replacing the p with a div still give me a div within a div? I added the css and link class to that final p tag, and that didn't work. Am I misunderstanding what you're telling me?
		 | 
|   |   | 
| Advert | |
|  | 
|  01-30-2016, 05:55 PM | #6 | 
| Sigil Developer            Posts: 9,071 Karma: 6361556 Join Date: Nov 2009 Device: many | 
			
			You do not need or want the internal span/div tag.  use just the p tag alone with the proper class and no span or div.  Or remove span and replace p tag with div.  You do not  need the nesting.  And fwiw, div tags can be nested in div tags, you just don't need it. Simply center a p tag or center a div, don't try to center a span inside of a p | 
|   |   | 
|  01-30-2016, 06:12 PM | #7 | |
| Member  Posts: 11 Karma: 10 Join Date: Jan 2016 Device: none | Quote: 
 | |
|   |   | 
|  01-30-2016, 06:20 PM | #8 | 
| Banned            Posts: 272 Karma: 1224588 Join Date: Sep 2014 Device: Sony PRS 650 | 
			
			What's the relation ship with Sigil? Why isn't this moved to the epub forum?
		 | 
|   |   | 
|  01-30-2016, 07:03 PM | #9 | 
| Grand Sorcerer            Posts: 28,880 Karma: 207000000 Join Date: Jan 2010 Device: Nexus 7, Kindle Fire HD | 
			
			It's OK to wander occasionally. They are using Sigil to do what they're doing.
		 | 
|   |   | 
|  01-31-2016, 01:11 AM | #10 | 
| Banned            Posts: 272 Karma: 1224588 Join Date: Sep 2014 Device: Sony PRS 650 | 
			
			What for is the epub forum than? This is Sigil, and the questuon is about html(epub2), I'm using Windows to run Sigil, and i'm not asking in Windows forums about that.
		 | 
|   |   | 
|  01-31-2016, 11:25 AM | #11 | 
| Member  Posts: 11 Karma: 10 Join Date: Jan 2016 Device: none | 
			
			KevinH and the Ducks, thanks again for your help with coding in SIGIL. All is working, and SIGIL Flightcrew validation shows my doc as error-free. Now, off to look at that new SIGIL version KevinH posted about...
		 | 
|   |   | 
|  02-07-2016, 03:08 AM | #12 | 
| frumious Bandersnatch            Posts: 7,570 Karma: 20150435 Join Date: Jan 2008 Location: Spaniard in Sweden Device: Cybook Orizon, Kobo Aura | 
			
			That's not exact. <div> is a block-level tag and can contain block or inline level tags. If I remember correctly inline tags (like <span>) can contain block level tags too, and the "type" of any tag (at least to the extent of how they are rendered) can be changed with the CSS "display" property. But <p> is a special case. It cannot contain block-level tags, not because it's block-level itself, but because it's <p> and it's defined that way. And the tags it cannot contain are those defined as block level by default, even if you change their "display". So this is forbidden: Code: <p><div>Foo</div></p> Code: <p><span style="display:block">Foo</span></p> | 
|   |   | 
|  | 
| Tags | 
| css classes, html attributes, sigil | 
| Thread Tools | Search this Thread | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| span in span: is this problematic? | tbuyus | ePub | 8 | 03-31-2013 08:01 AM | 
| ePub CSS @fontface Unicode chars render in <td>, not in <div>, other elements | Abelinkin | ePub | 2 | 06-05-2012 04:24 AM | 
| Remove <br /> together with span, and only span | Razzia | Recipes | 3 | 05-30-2011 06:55 PM | 
| CSS Questions | JTAL604622 | Calibre | 0 | 11-18-2010 06:33 PM | 
| Questions about <p> and <div> and paragraph spacing | droople | Sigil | 7 | 08-14-2010 12:03 PM |